imagecolorallocate in PHP 5.4

So, I know you’re supposed to call imagecolordeallocate and create new colors when you create a new image object. And test that your colors are created successfully. But really, who can be bothered? But, if you’re running the latest PHP 5.4 RC and seeing this in your console log:

3 libphp5.so 0x00000001081c34d1 php_request_shutdown + 1121 (main.c:1780)

Or this in a GDB backtrace:

#3 0x000000010172853f in php_request_shutdown (dummy=0x0) at main.c:1776

it might mean you’ve encountered this bug, and you need to care now.

Until PHP resolves this, the way you troubleshoot it is to run PHP through GDB (on my Mac, “sudo gdb /usr/sbin/httpd” and at the prompt type “run -X”). When PHP crashes, use GDB to print the contents of last_error_message as a string: That’s the file with the error. Then print the contents of last_error_file: That’s the line the error occurred on. What is the error? No idea. That information seems to have been shifted off into oblivion, but at least you have a line to stare at.

Hope that helps someone. And in the future, we should probably be better about checking return statuses and calling destructors…

About Bion

I'm a software developer at Modo Payments, a mobile payment provider. When I'm not hacking away the office, you I'm usually at home hacking on something else. Or practicing Aikido. Anyway, I just post things here that Google couldn't help me with, so maybe it'll help you in the future. Since you're reading this, I guess it worked :)
This entry was posted in Technology and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *