Cleanup all scopes before exiting a pseudo-forked process.
Jan Dubois [Wed, 2 Dec 2009 09:34:18 +0000 (01:34 -0800)]
perl_destruct() contains an assertion that the scope stack
is empty.  The remaining scopes are due to fork() being
called from within a BEGIN block.

win32/perlhost.h

index 61f8765..5e89f85 100644 (file)
@@ -1769,6 +1769,11 @@ restart:
        switch (status) {
        case 0:
            CALLRUNOPS(aTHX);
+            /* We may have additional unclosed scopes if fork() was called
+             * from within a BEGIN block.  See perlfork.pod for more details.
+             */
+           while (PL_scopestack_ix > oldscope)
+               LEAVE;
            status = 0;
            break;
        case 2: