Program locked at joinAll and sched_yield
Lodovico Giaretta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jul 3 11:56:58 PDT 2016
On Sunday, 3 July 2016 at 18:25:32 UTC, tcak wrote:
> Well, I actually have found out about the issue, and solved it
> a different way.
>
> I put memory limit on the process for testing.
>
> At some point, due to memory limitation, thread.start() method
> fails. But, this method cannot recover the system correctly,
> and Phobos thinks that thread has been started correctly.
>
> This happens, if I understand correctly, due to the value of
> variable "nAboutToStart" in core.thread, line 685. Its value is
> increase here, and is decreased by 1 in "add" function on line
> 1775. When start() fails, add() is not called for it ever, and
> thread_joinAll() on line 2271 gets into an endless loop. There
> by, the program cannot quit, and loop starts using 100% CPU.
>
> ---
>
> What I did to solve this issue is that I created my thread by
> using pthread_create() function, and called
> thread_attachThis(). This way, problem is prevented.
>
> ---
>
> As a solution, when thread creation is failed in start()
> method, we should decrease the value of "nAboutToStart" by 1,
> but it seems like "pAboutToStart" needs to be touched to
> recover the system properly. Fortunately there is not much code
> in the start() method.
I suggest you create an issue for this, if you didn't already, so
that it can be fixed.
More information about the Digitalmars-d-learn
mailing list