www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9122] New: std.concurrency send() fails with multiple arrays

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122

           Summary: std.concurrency send() fails with multiple arrays
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: john.loughran.colvin gmail.com


--- Comment #0 from John Colvin <john.loughran.colvin gmail.com> 2012-12-07
06:04:25 PST ---
import std.concurrency;
import std.stdio;

void foo() {
    bool running  = true;
    while(running) {
         receive(
        (immutable(double)[] a, immutable(double)[] b, int i) {
        writeln(a, b, i);
        },
        (OwnerTerminated e) {
        running = false;
        }
    );
    }
}

void main() {
    double[] a,b;
    a = [1.1];
    b = [2.2];
    int i= 3;

    auto tid = spawn(&foo);

    tid.send(a.idup, b.idup, i); 
}

I get: core.exception.AssertError  std/variant.d(277): target must be non-null

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 07 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


David Eagen <david eagen.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david eagen.com


--- Comment #1 from David Eagen <david eagen.com> 2013-01-03 04:44:21 PST ---
This is probably related to issue 7069. 

The problem also occurs on structs like this:

import std.concurrency, std.exception, std.stdio;

struct Combined
{
  string str1;
  string str2;
  bool status;
}

void main() {
   auto tid = spawn(&worker);
   Combined c = Combined("one", "two", false);
   tid.send(c);
}

void worker() {
  for (bool running = true; running; ) 
  {
    receive(
        (Combined c) 
        { 
          writeln("Got ", c.str1, "\t", c.str2, "\t", c.status);
        },

    (OwnerTerminated unused)
    {
      running = false;
    }    
    );
  }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


David Eagen <david eagen.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major


--- Comment #2 from David Eagen <david eagen.com> 2013-01-03 05:51:35 PST ---
Bumping importance. This issue makes it impossible for me to move to 2.061
because it breaks all my applications that use message passing for concurrency.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


David Eagen <david eagen.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


Martin Krejcirik <mk krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mk krej.cz


--- Comment #3 from Martin Krejcirik <mk krej.cz> 2013-03-31 15:59:08 PDT ---
Code from comment #1 works for me in 32 bit, but I get the same error message
("target must be non-null") when the size of a message (Combined.sizeof)
exceeds 24 bytes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


Zhenya Chapovsky <zheny list.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zheny list.ru


--- Comment #4 from Zhenya Chapovsky <zheny list.ru> 2013-04-19 10:02:44 PDT ---
Is anyone working on this issue?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9122


Tavi Cacina <octavian.cacina outlook.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |octavian.cacina outlook.com


--- Comment #5 from Tavi Cacina <octavian.cacina outlook.com> 2013-04-23
11:45:43 PDT ---
I hit this bug too as I wanted to send a structure. Martin Krejcirik was right
about the size of the structure. As soon as the message to be sent exceeds 20
bytes (win32) it comes to the assert. I see that the problem is with the
default generated opAssign for the struct Message in std.concurrency. This
Message has a "Variant data" attribute that needs to be copied. 

I could reproduce the error like this: 
---
struct S { int p1, p2, p3, p4, p5, p6; }
Variant v1 = S();
Variant v2;
v2 = v1; // assert
---

The Variant is defined like:
alias VariantN!(maxSize!(creal, char[], void delegate())) Variant;
so it has already a fixed size. The constructor can cope with the bigger size
and will adjust, but the opAssign does not. I do not know if it is a bug that
the constructor allows it or that the opAssign does not. 

A possible fix would be to add an opAssign operator to the Message structure:

---
ref Message opAssign(Message rhs) 
{ 
    type = rhs.type;
    swap(data, rhs.data); 
    return this; 
} 
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 23 2013