# efree() crash when used in a shutdown function

- Thread: https://externals.io/message/6216
- Original archive: https://news-web.php.net/php.internals/6216
- Started by Frank M. Kromann on 2003-12-04T20:29:24+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6216 — Frank M. Kromann — 2003-12-04T20:29:24+00:00

URL: https://externals.io/message/6216#6216

Hi,

From the pecl/printer extension:

static void php_printer_shutdown(zend_printer_globals *printer_globals
TSRMLS_DC) {
	if (printer_globals->default_printer) {
		efree(printer_globals->default_printer);
	}
}

PHP_MINIT_FUNCTION(printer)
{
    ZEND_INIT_MODULE_GLOBALS(printer, php_printer_init,
php_printer_shutdown);
..


This code fails when the module is shutting down. The mudule is compiled
against PHP5, and it works fine with PHP4.

If I change efree() to free() (and change the estrdup() to strdup()) the
code works fine. I have checked the string just before calling efree and
it is allocated and has a value.

Is there any problem calling efree() from a shutdown function ?

- Frank
> Hi,
> 
> stdlib.h is included in line 106 of bindlib_w32\conf\portability.h.
This
> causes the linker to look for __pctype and __mb_cur_max. This is not a
> problem for the old style builds but with Wez' new build system it
causes
> a linking problem.
> 
> Removing line 106 form this file solves the problem and as far as I can
> tell it does not cause any other problems.
> 
> - Frank
