On Fri, Jul 08, 2005 at 09:36:19AM +0100, Steve Hay wrote: > The crash is deliberately forced by win32_checkTLS(), but I don't > understand for what reason. PerlEnvGetenv() takes an IPerlEnv* and uses > the IPERL2HOST() macro (which is set to IPerlEnv2Host()) to locate the > CPerlHost* which that IPerlEnv* is a member of. It then calls > win32_checkTLS() to check that the host_perl in the CPerlHost* that has > been found is my_perl. Evidently, in this case host_perl != my_perl, so > it bombs out. > > Does anyone know what this my_perl is? What is the purpose of the > host_perl != my_perl check, and why might it be failing?
my_perl is a pointer to the current perl interpreter; in a threaded build, it's normally passed as an extra 1st arg to most functions (that's what all the pTHX/aTHX stuff is for); functions that don't get it passed can have 'dTHX;' at their start, which declares my_perl and determines it from thread-local storage (this is slow). win32_checkTLS() appears to be sanity checking that the passed host_perl is the same as the my_perl determined by dTHX; since is this happening during the middle of cloning, this isn't likely to be the case. The real question is why is PerlIO_debug() getting called for the first time during cloning? On my system, it's getting called much earlier, during perl_parse(). A second possibility is that it's not being called for the first time, but that in this code: PerlIO_debug(const char *fmt, ...) { va_list ap; dSYS; va_start(ap, fmt); if (!PL_perlio_debug_fd && !PL_tainting && PL_uid == PL_euid && PL_gid == PL_egid) { const char *s = PerlEnv_getenv("PERLIO_DEBUG"); if (s && *s) PL_perlio_debug_fd = PerlLIO_open3(s, O_WRONLY | O_CREAT | O_APPEND, 0666); else PL_perlio_debug_fd = -1; for some reason PerlLIO_open3() is setting PL_perlio_debug_fd to 0, so that each time PerlIO_debug is called, it will still do a PerlEnv_getenv("PERLIO_DEBUG"). Perhaps? Can you detemine when PerlIO_debug() is being called, and if whether it's calling PerlLIO_open3() and whether that's rturning 0? -- The perl5 internals are a complete mess. It's like Jenga - to get the perl5 tower taller and do something new you select a block somewhere in the middle, with trepidation pull it out slowly, and then carefully balance it somewhere new, hoping the whole edifice won't collapse as a result. - Nicholas Clark, based on an original by Simon Cozens.