# broken shutdown for dl()'d modules (HEAD)

- Thread: https://externals.io/message/12900
- Original archive: https://news-web.php.net/php.internals/12900
- Started by Wez Furlong on 2004-09-19T10:16:59+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

---

## #12900 — Wez Furlong — 2004-09-19T10:16:59+00:00

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

Just noticed some segfaults during shutdown of `dl()`'d modules from the 
CLI; this is what I see running under valgrind:

==19025== discard syms in 
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20040718/pdo_sqlite.so 
due to munmap()
==19025== discard syms in /usr/local/lib/libsqlite3.so.0.8.6 due to munmap()
==19025== discard syms in 
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20040718/pdo.so due 
to munmap()
==19025== Invalid read of size 4
==19025==    at 0x8184ABC: _zval_dtor (zend_variables.c:55)
==19025==    by 0x817C2E0: _zval_ptr_dtor (zend_execute_API.c:393)
==19025==    by 0x818BE8B: zend_hash_apply_deleter (zend_hash.c:574)
==19025==    by 0x818BF19: zend_hash_graceful_reverse_destroy 
(zend_hash.c:640)
==19025==    Address 0x4239AA24 is not stack'd, malloc'd or free'd
zsh: 19025 segmentation fault  valgrind /usr/local/php5/bin/php ./sqlite.php

This looks to be our old friend 
Mr.-access-pointers-and-functions-after-we-dlclosed-the-module.  Sure 
enough, removing the dlclose() call fixes the segfault.

This smells like a shutdown order problem; the script creates two 
objects, and if I unset them before the script end there is no segfault.

--Wez.
