Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Parallel::ForkManager dies with "Free to wrong pool..."

by sundialsvc4 (Abbot)
on Jun 15, 2018 at 13:29 UTC ( [id://1216710]=note: print w/replies, xml ) Need Help??


in reply to Parallel::ForkManager dies with "Free to wrong pool..."

Since the exception appears to be being thrown within Math::Prime::Util::GMP, this becomes my prime suspect.   Looking at line 132 on "metacpan.org," I see that it is call to _GMP_destroy() and that it occurs within an END block.   This source-code in turn can be found at https://github.com/danaj/Math-Prime-Util-GMP/blob/master/gmp_main.c.

My hypothesis now becomes that GMP, itself, is not thread/process safe.   That the actual root cause of your problem does not lie in your Perl code, but in the C-language implementation of GMP.   Of course this might be caused by some interaction with Perl’s implementation of threading, and/or with precisely what happens in an END-block, but the next experiment that I would perform is to cobble-up a C-language program that launches a number of C-language child processes to see if you can replicate the problem outside of the Perl environment.   I did not see any open or closed issues either on MetaCpan or GitHub that specifically talked about threading/process issues, but I don’t know how often the users of this package routinely attempt to use it that way.

Exploring the source-code for the term “memory,” I stumbled upon a reference in expr.c to an external, mp_get_memory_functions(), which is probably one step closer to the actual way that GMP does memory management.   If there is anything buried in the bowels of this thing which needs a mutex in a multi-process environment, this would be more than sufficient to cause a problem like this and to make it thoroughly unpredictable.   Perl would now be exonerated – and, I suspect, it is.

Replies are listed 'Best First'.
Re^2: Parallel::ForkManager dies with "Free to wrong pool..."
by perlygapes (Sexton) on Jun 15, 2018 at 17:32 UTC
    I give thanks for your answer to my supplications, sundialsvc4.
    I chant in unity with every utterance you have scribed.
    Indeed, mine own diligent study of scriptural truth did lead me to the very same line in the very same file.
    At this point I became aware of the true nature of this fallen state, and the need for a new plan of salvation for my children.
    The need to put something inside each child in order to inoculate it from ultimate death.

    As for GMP.pm...another plan of salvation is needed, one I cannot provide in this instantiated perl-verse

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216710]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found