Bug #69767 [NEW]: Default parameter value with wrong type segfaults

From: Date: Sun, 07 Jun 2015 12:42:04 +0000
Subject: Bug #69767 [NEW]: Default parameter value with wrong type segfaults
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193179@lists.php.net to get a copy of this message
From: cmb Operating system: Ubuntu 14.04, Windows 7 PHP version: master-Git-2015-06-07 (Git) Package: Reproducible crash Bug Type: Bug Bug description:Default parameter value with wrong type segfaults Description: ------------ When the default value of a function parameter doesn't match the given type, a segfault occurs. This happens with current master, and apparently, the bug has been introduced during May, cf. <http://3v4l.org/2qT7B>. Test script: --------------- <?php function foo(string $bar = '') {} ?> Expected result: ---------------- Default value for parameters with a string type hint can only be string or NULL in %s on line %d Actual result: -------------- #0 strlen () at ../sysdeps/x86_64/strlen.S:106 #1 0x000000000053ab18 in xbuf_format_converter ( xbuf=xbuf@entry=0x7fffffffa0c0, is_char=is_char@entry=1 '\001', fmt=0x794f1d "s type hint can only be %s or NULL", ap=0x7fffffffa210) at /home/cmb/php/php-src/main/spprintf.c:609 #2 0x000000000053b95a in vspprintf (pbuf=pbuf@entry=0x7fffffffa128, max_len=1024, format=<optimized out>, ap=<optimized out>) at /home/cmb/php/php-src/main/spprintf.c:848 #3 0x0000000000534ffd in php_error_cb (type=64, error_filename=0x7ffff7055248 "/home/cmb/php/php-src/test.php", error_lineno=3, format=<optimized out>, args=<optimized out>) at /home/cmb/php/php-src/main/main.c:965 #4 0x0000000000593979 in zend_error (type=type@entry=64, format=format@entry=0x794ef8 "Default value for parameters with a %s type hint can only be %s or NULL") at /home/cmb/php/php-src/Zend/zend.c:1180 #5 0x000000000057b4f5 in zend_compile_params ( ast=ast@entry=0x7ffff707a0c8, return_type_ast=return_type_ast@entry=0x0) at /home/cmb/php/php-src/Zend/zend_compile.c:4376 #6 0x00000000005825d0 in zend_compile_func_decl ( result=result@entry=0x0, ast=ast@entry=0x7ffff707a128) at /home/cmb/php/php-src/Zend/zend_compile.c:4685 #7 0x00000000005809ba in zend_compile_stmt ( ast=ast@entry=0x7ffff707a128) at /home/cmb/php/php-src/Zend/zend_compile.c:6831 #8 0x000000000058290a in zend_compile_top_stmt (ast=0x7ffff707a128) at /home/cmb/php/php-src/Zend/zend_compile.c:6753 #9 0x000000000058294f in zend_compile_top_stmt (ast=0x7ffff707a018) at /home/cmb/php/php-src/Zend/zend_compile.c:6748 #10 0x000000000055f50d in compile_file (file_handle=<optimized out>, type=<optimized out>) at Zend/zend_language_scanner.l:607 #11 0x0000000000593dd6 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3) at /home/cmb/php/php-src/Zend/zend.c:1383 #12 0x0000000000537d30 in php_execute_script ( primary_file=primary_file@entry=0x7fffffffcb20) at /home/cmb/php/php-src/main/main.c:2475 #13 0x0000000000619f8c in do_cli (argc=2, argv=0xa1e610) at /home/cmb/php/php-src/sapi/cli/php_cli.c:967 #14 0x000000000041e850 in main (argc=2, argv=0xa1e610) at /home/cmb/php/php-src/sapi/cli/php_cli.c:1334 -- Edit bug report at https://bugs.php.net/bug.php?id=69767&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69767&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69767&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69767&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69767&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69767&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69767&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69767&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69767&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69767&r=support Expected behavior: https://bugs.php.net/fix.php?id=69767&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69767&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69767&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69767&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69767&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69767&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69767&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69767&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69767&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69767&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69767&r=mysqlcfg

« previous php.bugs (#193179) next »