# dl() usage for cli php5

- Thread: https://externals.io/message/14256
- Original archive: https://news-web.php.net/php.internals/14256
- Started by Alan Knowles on 2005-01-01T07:11:32+00:00
- Messages: 3
- 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

---

## #14256 — Alan Knowles — 2005-01-01T07:11:32+00:00

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

I'm getting segfaults at shutdown when using `dl()`  with my extension - 
works perfectly if it's in php.ini (or if I run when compiled with 
--enable-debug

a) is this a known issue?
b) is it fixable for cli usage?

I'm guessing this is because modules are destroyed before the objects 
that they created are . looking at main/main.c 
:php_request_shutdown_for_hook() - a temporary fix may be to check for 
sapi == cli and skip the zend_deactivate_modules, and add it to the 
sapi_deactivate_cli..

Regards
Alan

---

## #14257 — Wez Furlong — 2005-01-01T14:30:19+00:00

URL: https://externals.io/message/14256#14257 · In reply to: #14256

This is still the broken shutdown order problem I've been moaning
about for some time; we're unloading the modules before we call the
dtors.

If you unset or assign to null all references to objects in your
extension before the script ends, you should end up with no segfault.

--Wez.



> I'm getting segfaults at shutdown when using `dl()`  with my extension -
> works perfectly if it's in php.ini (or if I run when compiled with
> --enable-debug
> 
> a) is this a known issue?
> b) is it fixable for cli usage?
> 
> I'm guessing this is because modules are destroyed before the objects
> that they created are . looking at main/main.c
> :php_request_shutdown_for_hook() - a temporary fix may be to check for
> sapi == cli and skip the zend_deactivate_modules, and add it to the
> sapi_deactivate_cli..
> 
> Regards
> Alan

---

## #14267 — Andi Gutmans — 2005-01-04T01:40:50+00:00

URL: https://externals.io/message/14256#14267 · In reply to: #14256

I can't quite remember the exact explanation but I think we have a chicken 
and the egg problem :'(

At 09:30 AM 1/1/2005 -0500, Wez Furlong wrote:
>This is still the broken shutdown order problem I've been moaning
>about for some time; we're unloading the modules before we call the
>dtors.
>
>If you unset or assign to null all references to objects in your
>extension before the script ends, you should end up with no segfault.
>
>--Wez.
>
>
>
> > […]
