[perl #90006] out of memory during thread clone
authorDavid Mitchell <davem@iabyn.com>
Mon, 6 Jun 2011 18:09:31 +0000 (19:09 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 6 Jun 2011 18:44:35 +0000 (19:44 +0100)
If you run out of memory during thread cloning, exit() may be called which
will unwind the context stacks, and be very unhappy if there aren't any.
Which there might not be if we haven't allocated any yet during cloning.

We can't just fix this by creating them earlier during the cloning
sequence, because creating them requires calling malloc(), which
may fail and exit...

So just check for this condition during stack unwind.

pp_ctl.c

index 043bef3..eed88f8 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1577,6 +1577,9 @@ Perl_dounwind(pTHX_ I32 cxix)
     dVAR;
     I32 optype;
 
+    if (!PL_curstackinfo) /* can happen if die during thread cloning */
+       return;
+
     while (cxstack_ix > cxix) {
        SV *sv;
         register PERL_CONTEXT *cx = &cxstack[cxstack_ix];