Strange bug in std.concurrency.spawn

Jose Armando Garcia jsancio at gmail.com
Mon Apr 4 21:19:08 PDT 2011


dmd can compile and run to follow the code:

unittest
{
   spawn(&fun);
}

void fun(int i) { writeln(i); }

Which if you are lucky segfaults and if you are unlucky prints
garbage! The problem is that spawn doesn't checks that the signature
of fun matches the number and type of variadic arguments. Is this a
bug in spawn(), a bug in dmd or a limitation of the language?

* If it is a bug in spawn, how can it be augmented to check this case?
* If this is a bug in dmd, I'll file a report.
* If this is a limitation of the language is this well known and it is
worked on? As it stands it doesn't seem possible to write safe
multi-threaded code.


More information about the Digitalmars-d-learn mailing list