Thread overview
[Issue 6135] New: Thread/GC interaction bug on OS X
Jun 09, 2011
klickverbot
Jun 09, 2011
klickverbot
Jun 10, 2011
klickverbot
Jun 17, 2011
klickverbot
Jun 17, 2011
klickverbot
Jun 17, 2011
Sean Kelly
Jun 17, 2011
Sean Kelly
Jul 21, 2011
klickverbot
June 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6135

           Summary: Thread/GC interaction bug on OS X
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@klickverbot.at


--- Comment #0 from klickverbot <code@klickverbot.at> 2011-06-09 13:36:40 PDT ---
Consider the following program:
---
import core.memory;
import core.thread;

void doNothing() {}

void main() {
  foreach (i; 0 .. 10000) {
    auto t = new Thread(&doNothing);
    t.start();
    GC.collect();
  }
}
---

With latest DMD (9aae5c4) and druntime (00ce4ab) on OS X, this triggers the
"Unable to load thread state" clause at core/thread.d:2280 during a GC
collection (which in turn triggers an onOutOfMemoryError() on allocating the
exception object because it happens during a GC runs, which accounts for #0-#5
in the backtrace below):
---
#0  0x00012787 in _d_throwc ()
#1  0x00009686 in onOutOfMemoryError ()
#2  0x0000e8b9 in D2gc3gcx2GC12mallocNoSyncMFkkPkZPv ()
#3  0x0000e855 in D2gc3gcx2GC6mallocMFkkPkZPv ()
#4  0x0000dc58 in gc_malloc ()
#5  0x000134bb in _d_newclass ()
#6  0x0000b558 in
D4core6thread17thread_suspendAllUZv7suspendMFC4core6thread6ThreadZv ()
#7  0x0000b447 in thread_suspendAll ()
#8  0x00010b75 in D2gc3gcx3Gcx11fullcollectMFPvZk ()
#9  0x00010b2d in D2gc3gcx3Gcx16fullcollectshellMFZk ()
#10 0x0000faf7 in D2gc3gcx2GC11fullCollectMFZk ()
#11 0x0000da59 in gc_collect ()
#12 0x000096bb in D4core6memory2GC7collectFZv ()
#13 0x000027ea in _Dmain ()
#14 0x000132df in D2rt6dmain24mainUiPPaZi7runMainMFZv ()
#15 0x00012e89 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#16 0x00013327 in D2rt6dmain24mainUiPPaZi6runAllMFZv ()
#17 0x00012e89 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#18 0x00012e23 in main ()
---

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



--- Comment #1 from klickverbot <code@klickverbot.at> 2011-06-09 13:55:00 PDT ---
The thread_get_state return code is 268435459 (0x10000003), probably
corresponding to MACH_SEND_INVALID_DEST (mach/message.h). Just a shot in the
dark, but maybe suspend() gets called for a thread that's no longer around?

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



--- Comment #2 from klickverbot <code@klickverbot.at> 2011-06-10 06:11:07 PDT ---
And indeed, t.isRunning is false when thread_get_state() is called.

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



--- Comment #3 from klickverbot <code@klickverbot.at> 2011-06-17 09:56:46 PDT ---
Fixed by Sean Kelly in https://github.com/D-Programming-Language/druntime/commit/45c4f1b94dddd091cc5aa72de7b0fddf76a6de21.

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


klickverbot <code@klickverbot.at> changed:

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


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


Sean Kelly <sean@invisibleduck.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |sean@invisibleduck.org
         Resolution|FIXED                       |


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


Sean Kelly <sean@invisibleduck.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |ASSIGNED


--- Comment #4 from Sean Kelly <sean@invisibleduck.org> 2011-06-17 10:30:05 PDT ---
Reopened to be marked as fixed with the 2.054 release.

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


klickverbot <code@klickverbot.at> changed:

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


--- Comment #5 from klickverbot <code@klickverbot.at> 2011-07-20 21:59:06 PDT ---
Closing, again, as 2.054 has been released in the meantime.

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