Re: spawn bug?
Sean Kelly Wrote: This one is weird, and doesn't appear related to 4307. One of the threads (thread A) is in a GC collection and blocked trying to acquire the mutex protecting the global thread list within thread_resumeAll. Another thread (thread B) is also blocked trying to acquire this mutex for other reasons. My best guess is that pthread_mutex in OSX is trying to give ownership of the lock to thread B, and since thread B is suspended it effectively blocks thread A from acquiring it to resume execution after the GC cycle. After some testing, it looks like I was right. I have a fix for this, but it's far from ideal (though the diff is small): require everything but thread_resumeAll to acquire two locks in sequence, while thread_resumeAll only acquires the second. I'll try to come up with something better.
Re: spawn bug?
I tried to get a bugzilla account but it never emailed me the verification. I'll try again and then try to figure out how to post this there. Thanks for looking into it. Adam
Re: spawn bug?
Okay, figured out puremagic a little. http://d.puremagic.com/issues/show_bug.cgi?id=5488
spawn bug?
The attached code usually hangs (running on OSX, dmd 2.051). It uses spawn to create a new thread. All the thread does is create a large array of doubles. In one case it uses the Array!double from std.container. In the other case it uses the built in dynamic double[]. It declares the array, sets the length, then sends a message to main saying it is finished and exits. The Array!double case always runs fine. The built-in dynamic array case usually hangs, though not always in the same place. And the array has to be sufficiently big (in my case 20 or bigger I think) or the problem doesn't occur. I've no idea why. It took me a *long* time to find this since it manifested as very mysterious hanging in a more complex piece of threaded code. Now I've switched to using Array!double in my code and it all works fine. Adam (An example run) Spawned foo 1 Spawned foo 2 Spawned foo 3 Spawned foo 4 Finished foo 1 Finished foo 2 Finished foo 3 Finished foo 4 Spawned bar 1 Spawned bar 2 Spawned bar 3 (stays here without finishing) begin 644 spawn.d M:6UP;W)T('-T9YC;VYC=7)R96YC3L*:6UP;W)T('-T9YS=1I;SL*:6UP M;W)T('-T9YC;VYT86EN97([FEM]R=!C;W)E+G1HF5A9#L*G9O:60@ M9F]O*'5I;G0@:RP@=6EN=!L+%1I9!M5ED*2`*PH@($%RF%Y(61O=6)L M92!AG([B`@87)R+FQE;F=T:AL*3L*(!S96YD*U4:60L:RD[GT*@IV M;VED()ABAU:6YT(LL('5I;G0@;Q4:60@;51I9D@GL*(!D;W5B;5; M72!AG([B`@87)R+FQE;F=T:`](P[B`@V5N9AM5ED+LI.PI]@H* M=F]I9!M86EN*D@GL*(!I;6UU=%B;4@=6EN=!M=6QT:7!L:65R(#T@ M,3`P,#`P.PH@(EM;75T86)L92!U:6YT(Y4:')E861S(#T@-#L*(!A=71O M(UA:6Y4:60@/2!T:ES5ED*D[@H@(9OF5A8V@@*L[(#$N+BAN5AR M96%DRLQ*2D@PH@(`@875T;R!D=6UM5]4:60@/2!S%W;B@F9F]O+LL M:RIM=6QT:7!L:65R+UA:6Y4:60I.PH@(`@=W)I=5F;XH(E-P87=N960@ M9F]O(5S(BQK*3L*(!]@H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@ M(!R96-E:79E*AU:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D(9O;R`E MR(L:BD[('TI.PH*(!F;W)E86-H(AK.R`Q+BXH;E1HF5A9',K,2DI('L* M(`@(%U=\@9'5M;7E?5ED(#T@W!A=VXH)F)ABQK+LJ;75L=EP;EE MBQM86EN5ED*3L*(`@('=R:71E9FQN*)3%W;F5D()AB`ER(L:RD[ MB`@?0H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@(!R96-E:79E*AU M:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D()AB`ER(L:BD[('TI.PH@ (`H@(`I] ` end
Re: spawn bug?
On Sunday 23 January 2011 20:34:16 Adam Conner-Sax wrote: The attached code usually hangs (running on OSX, dmd 2.051). It uses spawn to create a new thread. All the thread does is create a large array of doubles. In one case it uses the Array!double from std.container. In the other case it uses the built in dynamic double[]. It declares the array, sets the length, then sends a message to main saying it is finished and exits. The Array!double case always runs fine. The built-in dynamic array case usually hangs, though not always in the same place. And the array has to be sufficiently big (in my case 20 or bigger I think) or the problem doesn't occur. I've no idea why. It took me a *long* time to find this since it manifested as very mysterious hanging in a more complex piece of threaded code. Now I've switched to using Array!double in my code and it all works fine. Adam (An example run) Spawned foo 1 Spawned foo 2 Spawned foo 3 Spawned foo 4 Finished foo 1 Finished foo 2 Finished foo 3 Finished foo 4 Spawned bar 1 Spawned bar 2 Spawned bar 3 (stays here without finishing) begin 644 spawn.d M:6UP;W)T('-T9YC;VYC=7)R96YC3L*:6UP;W)T('-T9YS=1I;SL*:6UP M;W)T('-T9YC;VYT86EN97([FEM]R=!C;W)E+G1HF5A9#L*G9O:60@ M9F]O*'5I;G0@:RP@=6EN=!L+%1I9!M5ED*2`*PH@($%RF%Y(61O=6)L M92!AG([B`@87)R+FQE;F=T:AL*3L*(!S96YD*U4:60L:RD[GT*@IV M;VED()ABAU:6YT(LL('5I;G0@;Q4:60@;51I9D@GL*(!D;W5B;5; M72!AG([B`@87)R+FQE;F=T:`](P[B`@V5N9AM5ED+LI.PI]@H* M=F]I9!M86EN*D@GL*(!I;6UU=%B;4@=6EN=!M=6QT:7!L:65R(#T@ M,3`P,#`P.PH@(EM;75T86)L92!U:6YT(Y4:')E861S(#T@-#L*(!A=71O M(UA:6Y4:60@/2!T:ES5ED*D[@H@(9OF5A8V@@*L[(#$N+BAN5AR M96%DRLQ*2D@PH@(`@875T;R!D=6UM5]4:60@/2!S%W;B@F9F]O+LL M:RIM=6QT:7!L:65R+UA:6Y4:60I.PH@(`@=W)I=5F;XH(E-P87=N960@ M9F]O(5S(BQK*3L*(!]@H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@ M(!R96-E:79E*AU:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D(9O;R`E MR(L:BD[('TI.PH*(!F;W)E86-H(AK.R`Q+BXH;E1HF5A9',K,2DI('L* M(`@(%U=\@9'5M;7E?5ED(#T@W!A=VXH)F)ABQK+LJ;75L=EP;EE MBQM86EN5ED*3L*(`@('=R:71E9FQN*)3%W;F5D()AB`ER(L:RD[ MB`@?0H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@(!R96-E:79E*AU M:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D()AB`ER(L:BD[('TI.PH@ (`H@(`I] ` end Please don't post to the bug list. Ask about bugs on D.Learn or D, or just report them in the tracker. This list is only meant for receiving messages from the bug tracker. There are several spawn bugs: http://d.puremagic.com/issues/buglist.cgi?quicksearch=spawn This one seems a likely culprit: http://d.puremagic.com/issues/show_bug.cgi?id=4307 - Jonathan M Davis