Thread overview
[Issue 5537] New: invariant._d_invariant() failing in std.concurrency.MessageBox.get
Feb 07, 2011
Jonathan M Davis
Feb 15, 2011
Jonathan M Davis
Jan 21, 2012
Jonathan M Davis
February 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5537

           Summary: invariant._d_invariant() failing in
                    std.concurrency.MessageBox.get
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: jmdavisProg@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-02-06 20:32:06 PST ---
This program currently results in a segfault:

import std.concurrency;
import std.stdio;

void main()
{
    int currThreads = 0;
    enum maxThreads = 6;

    size_t totalThreads = 0;
    auto recProc = (Tid tid)
                   {
                       writeln(++totalThreads);
                   };

    for(size_t i = 0; i < 1_000; ++i)
    {
        if(currThreads < maxThreads)
            receiveTimeout(1, recProc);
        else
            receive(recProc);

        spawn(&threadFunc, thisTid);
    }

    while(currThreads > 0)
        receive(recProc);
}

void threadFunc(Tid parentTid)
{
    send(parentTid, thisTid);
}

This is using the latest versions of druntime and phobos from git. The stack trace I get with gdb is

#0  0x080ade03 in invariant._d_invariant() ()
#1  0x080a56cc in std.concurrency.MessageBox.get!(long,void delegate(Tid
tid)).get (this=0x0, _param_1=579319349254397504, _param_0=10000) at
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/concurrency.d:716
#2  0x080a56aa in std.concurrency.receiveTimeout!(void delegate(Tid
tid)).receiveTimeout (_param_1=579319349254397504, ms=1) at
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/concurrency.d:501
#3  0x080a27a5 in D main () at l.d:18
#4  0x080add86 in rt.dmain2.main() ()
#5  0x080add18 in rt.dmain2.main() ()
#6  0x080addca in rt.dmain2.main() ()
#7  0x080add18 in rt.dmain2.main() ()
#8  0x080adcc4 in main ()

If I simplify the program that it uses only receive and not receiveTimeout, it still fails, so it's not an issue specific to receiveTimeout. I have also confirmed that the check-in 94bd4f661be79db34faedf76ca139115a07a9dd3 (Issue 4307 - spawn()'ed thread doesn't terminate) didn't cause the problem.

I have no idea what invariant._d_invariant() is - std.concurrency doesn't have any invariants in it - but this bug makes spawn utterly useless.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5537



--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-02-14 21:32:31 PST ---
Using git-bisect, I have confirmed that it is this commit to Phobos which broke it:

https://github.com/D-Programming-Language/phobos/commit/ecc7390670a122dec11183cbefbef2e7d9477921

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5537


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-01-20 23:16:00 PST ---
This no longer segfaults, so I assume that the issue has been fixed.

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