From: Gurusamy Sarathy Date: Fri, 25 Jul 1997 03:56:36 +0000 (+1200) Subject: Embedding threaded apps in perl.dll X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4dd614da4d1132b957c4951dd00f64d81b89dc20;p=p5sagit%2Fp5-mst-13.2.git Embedding threaded apps in perl.dll [Resend: I forgot to cc p5p] On Fri, 25 Jul 1997 17:22:09 EDT, Doug MacEachern wrote: >> >Were you able to run Apache w/ mod_status & perl? >> >> Not yet, maybe tonight. > >Now I get "Unhandled execption in Apache.exe(PERL.DLL); 0x...: >Access Violation." During perl_alloc(), win32_malloc() tries to >pIOSubSystem->pfnmalloc(size), but it looks like pIOSubSystem has not >been initialized at all (0x00000000). I've poked around, guessing, >tried adding: >PERL_SYS_INIT(&argc,&args); >SetIOSubSystem(&win32stdio); The first thing I noticed was Apache is threaded, and mod_status code will be invoked in a thread different from the main one. The second thing I found out was I couldn't reproduce the problem when running Apache with perl.dll produced by Borland. Putting two and one together, I came up with this fix. Note that another way to fix it would be to initialize pIOSubSystem in DllMain's DLL_THREAD_ATTACH, but there is no call for pIOSubSystem to be thread-local in the first place (it is simply a pointer to an application level global). p5p-msgid: 199707261518.LAA24346@aatma.engin.umich.edu --- diff --git a/win32/win32.c b/win32/win32.c index 6fbe733..653cdf7 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -34,10 +34,7 @@ static DWORD IdOS(void); extern WIN32_IOSUBSYSTEM win32stdio; -#ifndef __BORLANDC__ /* pointers cannot be declared TLS! */ -__declspec(thread) -#endif -PWIN32_IOSUBSYSTEM pIOSubSystem = &win32stdio; +static PWIN32_IOSUBSYSTEM pIOSubSystem = &win32stdio; BOOL ProbeEnv = FALSE; DWORD Win32System = (DWORD)-1;