Re: [PHP-DEV] Bug #4008: PHP crashes in module shutdown From: Zeev Suraski (zeev <email protected>)
Date: 04/03/00

At 06:39 03/04/2000 , dean.bennett <email protected> wrote:
>From: dean.bennett <email protected>
>Operating system: Windows 98 & NT
>PHP version: 3.0.15
>PHP Bug Type: Reproduceable crash
>Bug description: PHP crashes in module shutdown
>
>I have been porting the Sybase module to work on Windows platforms, and
>had a crash that would occur after php processed the file. It would occur
>if the dll was loaded with extension= in the php3.ini file, but NOT if the
>dll was loaded with the dl() function.
>
>The sybase module allocates some memory in the php3_rinit_sybase()
>function and releases it in php3_rshutdown_sybase(). The crash occurs in
>the efree call (which does a memset to the memory when the module is
>compiled in DEBUG mode).
>
>In main.c, the function php3_module_startup() calls
>start_memory_manager(), a bunch of init routines,
>module_startup_modules(), and then shutdown_memory_manager(). The call
>to shutdown_memory_manager() nukes the memory on Windows (fills it with
>0xdd), which causes it to crash when it tries to free the memory when the
>module shutdown is called.
>
>Removing the call to shutdown_memory_manager() prevents the crash. It
>seems a little odd to shutdown the memory manager in a startup
>routine. Perhaps this was meant to be called if the module startups failed?

No, it's intentional. Memory allocated during the initial startup of PHP
isn't supposed to persist; If you wish it to persist, you should use
malloc() directly (instead of emalloc()).

Zeev

--
Zeev Suraski   <zeev <email protected>>  http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>