develooper Front page | perl.perl5.porters | Postings from August 2009

Re: [perl #66158] fork crashes on perl 5.10.0/Win32 [PATCHproposal]

From:
Dave Mitchell
Date:
August 5, 2009 06:34
Subject:
Re: [perl #66158] fork crashes on perl 5.10.0/Win32 [PATCHproposal]
Message ID:
20090805133355.GL4204@iabyn.com
On Wed, Aug 05, 2009 at 03:16:05PM +0200, Vincent Pit wrote:
> > The thing that puzzles me is that is doesn't explode on 5.8.x.
> 
> I've no idea about why it works with 5.8, nor why the pointer table is
> flushed for the fork emulation but not for threads.

That was a change to threads.xs a while ago. Originally neither kept the
table around - its an expensive use of memory (at least 12 bytes per SV
etc per thread). MY_CXT_CLONE was only introduced in 5.8.6, so before that
VMG_THREADSAFE would be 0.

Anyway, I've caved in and applied the following to commits (the first is
cosmetic). Since I haven't got windows they've been applied blindly, so
Curtis, if you can test on then on windows ASAP that would be good.

commit 46a76da79aa70ae5c77ffe23d8c6e303c7c67ce2
Author:     David Mitchell <davem@iabyn.com>
AuthorDate: Wed Aug 5 14:18:37 2009 +0100
Commit:     David Mitchell <davem@iabyn.com>
CommitDate: Wed Aug 5 14:18:37 2009 +0100

    win32/perlhost.h: use symbolic constant
    CLONEf_COPY_STACKS rather than 1


Affected files ...
    
    M	win32/perlhost.h

Differences ...

diff --git a/win32/perlhost.h b/win32/perlhost.h
index 6e3fcd2..c2473c9 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1835,7 +1835,8 @@ PerlProcFork(struct IPerlProc* piPerl)
 	return -1;
     }
     h = new CPerlHost(*(CPerlHost*)w32_internal_host);
-    PerlInterpreter *new_perl = perl_clone_using((PerlInterpreter*)aTHX, 1,
+    PerlInterpreter *new_perl = perl_clone_using((PerlInterpreter*)aTHX,
+						 CLONEf_COPY_STACKS,
 						 h->m_pHostperlMem,
 						 h->m_pHostperlMemShared,
 						 h->m_pHostperlMemParse,



commit 240bfeb992996de28603a7f9e3ee34ecc6e3f286
Author:     David Mitchell <davem@iabyn.com>
AuthorDate: Wed Aug 5 14:20:29 2009 +0100
Commit:     David Mitchell <davem@iabyn.com>
CommitDate: Wed Aug 5 14:20:29 2009 +0100

    add CLONEf_KEEP_PTR_TABLE to win fork emulation.
    This keeps the ptr-table table around after the thread has been created.
    This has been on for user threads for a while now, but not for
    Windows forks. Turns out that Variable::Magic relies on the table still
    being there, so crashes under windows forks.  This increases memory usage
    per fork, but stops things crashing. Sigh.
    [perl #66158]


Affected files ...
    
    M	win32/perlhost.h

Differences ...

diff --git a/win32/perlhost.h b/win32/perlhost.h
index c2473c9..c02d409 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1836,7 +1836,8 @@ PerlProcFork(struct IPerlProc* piPerl)
     }
     h = new CPerlHost(*(CPerlHost*)w32_internal_host);
     PerlInterpreter *new_perl = perl_clone_using((PerlInterpreter*)aTHX,
-						 CLONEf_COPY_STACKS,
+						   CLONEf_COPY_STACKS
+						 | CLONEf_KEEP_PTR_TABLE,
 						 h->m_pHostperlMem,
 						 h->m_pHostperlMemShared,
 						 h->m_pHostperlMemParse,


-- 
Now is the discount of our winter tent
    -- sign seen outside camping shop



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About