# Seg fault with custom extension on dlclose

- Thread: https://externals.io/message/59765
- Original archive: https://news-web.php.net/php.internals/59765
- Started by Luke Scott on 2012-04-11T23:30:23+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

---

## #59765 — Luke Scott — 2012-04-11T23:30:23+00:00

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

I'm writing an extension that uses Google's V8 engine. I'm getting a
segfault after my module has been unloaded.

Here is what I get when running PHP:

DYLD_PRINT_LIBRARIES_POST_LAUNCH=1 /phpdev/bin/php -f
/Server/www/localhost/test.php
dyld: loaded: /phpdev/lib/php/extensions/debug-zts-20090626/v8php.so
dyld: loaded: /phpdev/lib/libv8.dylib
string(11) "Hello World"
dyld: unloaded: /phpdev/lib/php/extensions/debug-zts-20090626/v8php.so
dyld: unloaded: /phpdev/lib/libv8.dylib
Segmentation fault (core dumped)

This is the stack trace of the core dump:

#0  0x00007fff5fc1face in __dyld_munmap ()
#1  0x00007fff5fc10e8c in __dyld__ZN23ImageLoaderMachOClassicD0Ev ()
#2  0x00007fff5fc04bad in __dyld__ZN4dyld20garbageCollectImagesEv ()
#3  0x00007fff5fc09e9a in __dyld_dlclose ()
#4  0x00007fff83133665 in dlclose ()
#5  0x00000001005baa8c in module_destructor (module=0x100d52c10) at
zend_API.c:2138
#6  0x00000001005c6927 in zend_hash_apply_deleter (ht=0x100a748e0,
p=0x100d52bc0) at zend_hash.c:612
#7  0x00000001005c6b38 in zend_hash_graceful_reverse_destroy
(ht=0x100a748e0) at zend_hash.c:647
#8  0x00000001005aa6e4 in zend_shutdown (tsrm_ls=0x100d000f0) at zend.c:759
#9  0x00000001004e9935 in php_module_shutdown (tsrm_ls=0x100d000f0) at
main.c:2186
#10 0x000000010071bb0e in main (argc=3, argv=0x7fff5fbffa30) at
php_cli.c:1377

Here is the test PHP code:

$v8 = new V8();
var_dump($v8->run("'Hello World'"));

The "run" function is almost identical to the second snippet on this page:
https://developers.google.com/v8/get_started , difference being I'm doing
RETURN_STRING(*ascii, 1).

(If providing a core dump helps, I can do that as well)

Anyone know what could be causing this?

Luke
