Found a strange bug where when trying to send a message of some struct the sender thread silently dies. However with different struct layout everything works fine. I'm using DMD 2.062 under Windows. Here's a code sample:

import std.concurrency, std.stdio, core.time;

struct Msg {
        string name;
        int sz;
        double progress;
}

void myfun(Tid tid)
{
        writeln("10");
        tid.send(Msg("a", 123, 0.2));
        writeln("20");
}

void main(string[] argv)
{
        int[] arr = [1,2,3];
        spawn(&myfun, thisTid);

        void RcvMsgAnalyzing(Msg m)
        {
                writeln(m.sz);
        }

        while(true) {
                while(receiveTimeout(dur!"msecs"(100), &RcvMsgAnalyzing)) {}
        }
}

When run like this it prints "10" and then nothing happens, and the Task Manager shows there is only 1 thread working after that. But if you comment out any field of Msg struct leaving the other two (and correct Msg instance creation) then it works just fine, the message gets delivered and worker thread function runs to its end.

Debugger shows something goes wrong at concurrency.d line 572:
tid.mbox.put( msg );
Something inside variant.d goes mad but I haven't figured out yet what exactly.

Reply via email to