Jump to content

Memory issues, segfaults, and other strangeness


Macuyiko

Recommended Posts

I've been having all sorts of problems with PHP lately, using a specific ODBC driver. I already posted this on some other forums so I'm copy-pasting my text if you don't mind. I hope I posted in the correct forum, since I suspect this has to do with a PHP CORE issue/bug.

 

1 - PHP 5.2.1, 64 bit. Installed the ODBC driver, works fine using isql! I'm on Ubuntu Feisty. I try the odbc functions in PHP. Strangely enough, on some queries PHP crashes and Apache wants me to download a blank .php file. No errors, no nothing. So I try running the script using CLI, I get the following output:

 

snip: complete generated page output, using odbc_result_all();
freeing result, using odbc_free_result()
[...]
zend_mm_heap corrupted

 

Zend_mm_heap? I search on Google, more people are having this problem in 5.2.1, not in php-odbc though.

 

2 - PHP 5.2.3, still 64 bit and Ubuntu. Still the same problem, now I get:

[Thu Jul 19 21:02:51 2007] [notice] child pid 12548 exit signal Segmentation fault (11)

Segmentation fault? That's even worse, I downgrade again.

 

3 - XAMPP with PHP 5.2.3, this is a 32 bit installation. I fetch all the 32 bit libs and the use the 32 bit ODBC driver. It works, no errors. But I would rather avoid using a 32 bit mess on a 64 bit OS... So either php-odbc 64 bit is buggy, or the 64 bit driver. But both work fine using isql...

 

4 - CentOS ("maybe it's a bug in the Ubuntu packages"), 64 bit. PHP 5.1.6. Again, a different error:

freeing result*** glibc detected *** /usr/bin/php: free(): invalid pointer: 0x00000000153fc920 ***

I search on Google, I finally figure out you can suppress these errors with the MALLOC_CHECK_ environment variable. I try exporting it on the CLI and run the script through PHP-CLI. No errors. I'm not completely happy, but it works.

 

Apache is still failing though, how to set that environment variable. I try using the PHP putenv(); function, which fails. "Maybe I have to do this before loading PHP, makes sense." So I add this to my Apache configuration:

SetEnv MALLOC_CHECK_ 1

Sure enough, it now works in Apache too. I'm happy, but I'm not there yet.

 

5 - Back at Ubuntu with PHP 5.2.1 64 bit. I try the MALLOC_CHECK_ trick. Again the blank page. I try running it in CLI, again zend_mm_heap corrupted. Apparently this version is doing its own memory management. I find that in PHP 5.2.x you can use ZEND_MM_SEG_SIZE, ZEND_MM_TYPE and USE_ZEND_ALLOC, so I try exporting:

export ZEND_MM_SEG_SIZE=1M
export ZEND_MM_TYPE=mmap_anon
export USE_ZEND_ALLOC=0

The error disappears, USE_ZEND_ALLOC did the trick. So I try getting phpinfo(); from PHP-CLI, I see:

Zend Memory Management => disabled

 

So I try to put this into Apache (php-mod). So I add the following to my Apache configuration, just as I did before:

SetEnv USE_ZEND_ALLOC 0

I reload and try. It doesn't work. It's still getting "zend_mm_heap corrupted"-errors (which I can see in error.log). I try getting phpinfo(); through Apache:

Zend Memory Management: enabled

 

Why wasn't it disabled? Is it impossible to disable in Apache? Disabling works in PHP-CLI though, so I'm really scratching my head. Also, when I use getenv('USE_ZEND_ALLOC'), it shows the correct value ("0"), so why does PHP ignore it?

 

(6 - Last resort, trying the USE_ZEND_ALLOC and MALLOC_CHECK_ tricks on PHP 5.2.3. Doesn't work either.)

 

So the question is, in short: can I disable Zend Memory Management in php-mod (Apache)?

 

Thanks for reading all this and for your help.

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.