|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2014-06-18 22:03 UTC] af+debian-bugreports at chaos-agency dot de
[2014-06-23 08:12 UTC] tyrael@php.net
[2014-06-23 08:12 UTC] tyrael@php.net
-Status: Open
+Status: Closed
[2014-06-23 08:15 UTC] tyrael@php.net
[2014-06-30 20:23 UTC] dmitry@php.net
[2014-07-02 01:41 UTC] tyrael@php.net
[2014-07-02 08:26 UTC] ab@php.net
[2014-07-02 08:33 UTC] ab@php.net
[2023-06-15 10:00 UTC] giw42161 at uooos dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ The highlight_string() and highlight_file() functions segfault reliably when encountering a '__CLASS__' token in the source whenever the pgsql.so module is loaded. With pgsql.so loaded, the test script below segfaults, without pgsql.so it runs fine. No other module affects the problem, only whether pgsql.so is loaded or not makes a difference. Also, the pgsql.so only has to be loaded to induce the crash, you do not have to use any of its functions. I originally encountered the bug with the debian testing php packages (based on 5.6.0beta4), however I could reproduce it using the latest 5.6 snapshot (php5.6-201406181630) as well. Configure command for the snapshot test build was: % ./configure --prefix=... --with-pgsql=shared,/usr/bin/pg_config The architecture is AMD64, libpq5 is from PostgreSQL 9.3.4. No php.ini, just the builtin defaults. When running the test script using ".../php test.php", it works fine, however when using ".../php -d extension=pgsql.so test.php", it segfaults. The same thing happens when using php-cgi instead of php. With the debian package the same thing happens using the Apache2 file-handler SAPI. I didn't test the Apache SAPI with the snapshot, however I think the outcome would be the same. The segfault happens right after outputting the __CLASS__ itself. It does not segfault however when replacing the __CLASS__ with other magic builtin constants like __FILE__ or __LINE__. The segfault also does not occur with PHP 5.5.x, with everything else on the system the same. The bug seriously hampers PHP development using for example the popular Symfony framework. Symfony uses highlight_file() for more user-friendly uncaught exception and error reports, so it is a major problem when your PHP crashes everytime an uncaught exception happens, instead of displaying the error and letting you debug it. Therefore I hope this gets fixed before the 5.6 release. If you need more information or want me to test any patches, please contact me. Thanks in advance. Andreas Ferber Test script: --------------- <?php $s = <<<EOT <?php __CLASS__; EOT; highlight_string($s); ?> Actual result: -------------- Core was generated by `./bin/php -d extension=pgsql.so /home/sunshine/php-bug/test.php'. Program terminated with signal 11, Segmentation fault. #0 _zend_mm_free_int (heap=0x2217d40, p=0x7f98c0b10058) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend_alloc.c:2104 2104 if (ZEND_MM_IS_FREE_BLOCK(next_block)) { (gdb) bt #0 _zend_mm_free_int (heap=0x2217d40, p=0x7f98c0b10058) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend_alloc.c:2104 #1 0x0000000000693238 in zend_highlight ( syntax_highlighter_ini=syntax_highlighter_ini@entry=0x7fff5e5e6520) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend_highlight.c:153 #2 0x0000000000668be5 in highlight_string (str=0x7fff5e5e6400, syntax_highlighter_ini=syntax_highlighter_ini@entry=0x7fff5e5e6520, str_name=str_name@entry=0x7f98c0c4b318 "/home/sunshine/php-bug/test.php(6) : highlighted code") at Zend/zend_language_scanner.l:818 #3 0x00000000005dc826 in zif_highlight_string (ht=<optimized out>, return_value=0x7f98c0c49878, return_value_ptr=<optimized out>, this_ptr=<optimized out>, return_value_used=<optimized out>) at /home/sunshine/php-bug/php5.6-201406181630/ext/standard/basic_functions.c:5266 #4 0x000000000074a21c in zend_do_fcall_common_helper_SPEC (execute_data=0x7f98c0c13108) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend_vm_execute.h:558 #5 0x00000000006d6438 in execute_ex (execute_data=0x7f98c0c13108) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend_vm_execute.h:363 #6 0x00000000006a16ab in zend_execute_scripts (type=35749184, type@entry=8, retval=0x7f98c0b10058, retval@entry=0x0, file_count=-2124207320, file_count@entry=3) at /home/sunshine/php-bug/php5.6-201406181630/Zend/zend.c:1330 #7 0x000000000063f581 in php_execute_script (primary_file=0x7fff5e5e8ae0) at /home/sunshine/php-bug/php5.6-201406181630/main/main.c:2584 #8 0x000000000074bc99 in do_cli (argc=35749184, argv=0x7f98c0b10058) at /home/sunshine/php-bug/php5.6-201406181630/sapi/cli/php_cli.c:994 #9 0x0000000000426507 in main (argc=35749184, argv=0x7f98c0b10058) at /home/sunshine/php-bug/php5.6-201406181630/sapi/cli/php_cli.c:1378