Bert JW Regeer (畢傑龍)

PHP 5.2.6 on FreeBSD with extensions

There seems to be an issue in PHP 5.2.6 with extensions where the extensions have to be loaded in a certain order or the PHP interpreter has a tendency to crash and fail miserably. It is weird, as depending on the system configuration the order of the extensions has to be entirely different.

Certain extensions have a dependency on other extensions and their functionality so it is understandable that they are required to be loaded before the other modules can be loaded, however this has never been an issue before. I am not entirely sure how PHP does it, but I am betting it loads all the modules and then runs an init function of sort, and since all the modules are loaded at the same time, there are no issues.

However, in this case it seems that multiple functions are clashing, or something along those lines.

Running PHP in a gdb session showed the following:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x29803544 in __do_global_dtors_aux () from /usr/local/lib/php/20060613/
#2  0x29807c04 in _fini () from /usr/local/lib/php/20060613/
#3  0x2824f558 in tls_dtv_generation () from /libexec/
#4  0x28251558 in ?? () from /libexec/
#5  0xbfbfe9c8 in ?? ()
#6  0x282327b6 in elf_hash () from /libexec/
#7  0x282350a0 in dlclose () from /libexec/
#8  0x081374e4 in zend_hash_apply_deleter ()
#9  0x0813757f in zend_hash_graceful_reverse_destroy ()
#10 0x0812da7c in zend_shutdown ()
#11 0x080f4f67 in php_module_shutdown ()
#12 0x081aa892 in main ()

So it seems that simplexml is the culprit here, lets remove it. Once removed from extensions.ini we re-run gdb and give it the same information we gave it before, this time however we see this:

Cannot load module 'SPL' because required module 'simplexml' is not loaded in Unknown on line 0

My gut instinct is to now move simplexml ABOVE the line that says After we do this, PHP is able to run without any issues. Now, for the fun:

Is the extension list on one of the servers I administrate. Notice that is at the top of the file, and is somewhere in the middle. And this works perfectly, however the same file on a second server causes it to bomb spectacularly. However, I had kept a backup of the original extensions.ini on the second server, put it back, and then experimented with it, and this is what came out:

Now when I tried this on the first system where that first configuration file comes from, it bombs spectacularly leaving a core-dump. I have NO IDEA what is going on. I just know that log messages like the following:

pid 54662 (php-cgi), uid 80: exited on signal 11 (core dumped)
pid 54655 (php-cgi), uid 80: exited on signal 11 (core dumped)
pid 54658 (php-cgi), uid 80: exited on signal 11 (core dumped)
pid 54661 (php-cgi), uid 80: exited on signal 11 (core dumped)
pid 54660 (php-cgi), uid 80: exited on signal 11 (core dumped)

are a thing of the past, until next time when I upgrade or re-compile PHP and the order is played with again.

If you have any hints, insights or knowledge of what is going on, and what magic order I have to place the extensions in, please let me know by sending me an email at xistence@gmail. This is going to be a mystery, for now, as I definitely don't have the time to figure out what is going on and why.