Bug #51243 [NEW]: syntax error in autoload causes segmentation fault

From: Date: Tue, 09 Mar 2010 02:56:14 +0000
Subject: Bug #51243 [NEW]: syntax error in autoload causes segmentation fault
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148416@lists.php.net to get a copy of this message
From:             
Operating system: CentOS5.*
PHP version:      5.3.2
Package:          Apache2 related
Bug Type:         Bug
Bug description:syntax error in autoload causes segmentation fault 

Description:
------------
Segmentation fault was occured when the file was loaded by calling
require() or 
inclede() inside of autoload function ,
and it contains some php syntax error.

It is often happend.
The most case is after make changes of script repeatedly.

Test script:
---------------
=== C.php ===
<?php

class C{
  funct ion pr(){ print 123; }  // <-- syntax error
}

==== test.php ====
<?php

class Loader{
  function autoload($classname){ require "$classname.php" ;}
}

$loader  = new Loader();
spl_autoload_register(array($loader,'autoload'));

$c = new C();
$c->pr();

Expected result:
----------------
Report syntax error.

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0xb79dcb28 in zend_mm_check_ptr (heap=0x81b8a10, ptr=0x841fc78, silent=0, 
__zend_filename=0xb7f3234b "Zend/zend_language_scanner.l",
__zend_lineno=685, 
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at /s/php-5.3.2/Zend/zend_alloc.c:1355
1355            if (p->info._prev != ZEND_MM_GUARD_BLOCK &&
(gdb) bt
#0  0xb79dcb28 in zend_mm_check_ptr (heap=0x81b8a10, ptr=0x841fc78,
silent=0, 
__zend_filename=0xb7f3234b "Zend/zend_language_scanner.l",
__zend_lineno=685, 
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at /s/php-5.3.2/Zend/zend_alloc.c:1355
#1  0xb79dcaff in zend_mm_check_ptr (heap=0x81b8a10, ptr=0x841fc78,
silent=1, 
__zend_filename=0xb7f3234b "Zend/zend_language_scanner.l",
__zend_lineno=685, 
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at /s/php-5.3.2/Zend/zend_alloc.c:1352
#2  0xb79de08c in _zend_mm_free_int (heap=0x81b8a10, p=0x841fc78, 
__zend_filename=0xb7f3234b "Zend/zend_language_scanner.l",
__zend_lineno=685, 
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at /s/php-5.3.2/Zend/zend_alloc.c:1983
#3  0xb79df163 in _efree (ptr=0x841fc78, __zend_filename=0xb7f3234b 
"Zend/zend_language_scanner.l", __zend_lineno=685,
__zend_orig_filename=0x0, 
__zend_orig_lineno=0)
    at /s/php-5.3.2/Zend/zend_alloc.c:2351
#4  0xb79c6105 in zend_multibyte_read_script (buf=0xb7157000
"<?php\n\nclass 
C{\n  funct ion pr(){ print 123; }\n}\n\n", n=50) at 
Zend/zend_language_scanner.l:685
#5  0xb79c5083 in open_file_for_scanning (file_handle=0xbf848aa0) at 
Zend/zend_language_scanner.l:263
#6  0xb79c5290 in compile_file (file_handle=0xbf848aa0, type=8) at 
Zend/zend_language_scanner.l:331
#7  0xb77d0015 in phar_compile_file (file_handle=0xbf848aa0, type=8) at
/s/php-
5.3.2/ext/phar/phar.c:3390
#8  0xb6dabbba in xdebug_compile_file (file_handle=0xbf848aa0, type=8) at 
/s/xdebug-2.0.5/xdebug.c:2405
#9  0xb6d81060 in eaccelerator_compile_file (file_handle=0xbf848aa0,
type=8) at 
/s/eaccelerator-0.9.6/eaccelerator.c:1252
#10 0xb79c546a in compile_filename (type=8, filename=0x8420ebc) at 
Zend/zend_language_scanner.l:386
#11 0xb7a33dd7 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER 
(execute_data=0x8450258) at /s/php-5.3.2/Zend/zend_vm_execute.h:1916
#12 0xb7a2dbe4 in execute (op_array=0x842205c) at /s/php-
5.3.2/Zend/zend_vm_execute.h:104
#13 0xb6da9456 in xdebug_execute (op_array=0x842205c) at /s/xdebug-
2.0.5/xdebug.c:1562
#14 0xb79f2f5c in zend_call_function (fci=0xbf848ea4, fci_cache=0xbf848e74)
at 
/s/php-5.3.2/Zend/zend_execute_API.c:947
#15 0xb7a1be08 in zend_call_method (object_pp=0x841d5d8, obj_ce=0x84208bc,

fn_proxy=0x841d5d4, function_name=0x841f1c8 "x::autoload\001", 
function_name_len=16, retval_ptr_ptr=0xbf848f44,
    param_count=1, arg1=0x841eed8, arg2=0x0) at /s/php-
5.3.2/Zend/zend_interfaces.c:97
#16 0xb7871cfc in zif_spl_autoload_call (ht=1, return_value=0x841fd94, 
return_value_ptr=0xbf849130, this_ptr=0x0, return_value_used=1) at /s/php-
5.3.2/ext/spl/php_spl.c:395
#17 0xb79f30f4 in zend_call_function (fci=0xbf84910c, fci_cache=0xbf8490f8)
at 
/s/php-5.3.2/Zend/zend_execute_API.c:969
#18 0xb79f385d in zend_lookup_class_ex (name=0x8422190 "C", name_length=1,

use_autoload=1, ce=0xbf84919c) at
/s/php-5.3.2/Zend/zend_execute_API.c:1100
#19 0xb79f44b0 in zend_fetch_class (class_name=0x8422190 "C",
class_name_len=1, 
fetch_type=4) at /s/php-5.3.2/Zend/zend_execute_API.c:1542
#20 0xb7a30966 in ZEND_FETCH_CLASS_SPEC_CONST_HANDLER
(execute_data=0x84501b8) 
at /s/php-5.3.2/Zend/zend_vm_execute.h:724
#21 0xb7a308df in ZEND_USER_OPCODE_SPEC_HANDLER (execute_data=0x84501b8) at

/s/php-5.3.2/Zend/zend_vm_execute.h:703
#22 0xb7a2dbe4 in execute (op_array=0x841eb88) at /s/php-
5.3.2/Zend/zend_vm_execute.h:104
#23 0xb6da9456 in xdebug_execute (op_array=0x841eb88) at /s/xdebug-
2.0.5/xdebug.c:1562
#24 0xb7a0139d in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at 
/s/php-5.3.2/Zend/zend.c:1194
#25 0xb79954b6 in php_execute_script (primary_file=0xbf84b65c) at /s/php-
5.3.2/main/main.c:2260
#26 0xb7acb392 in php_handler (r=0x83a1538) at /s/php-
5.3.2/sapi/apache2handler/sapi_apache2.c:655
#27 0x0807f629 in ap_run_handler (r=0x83a1538) at config.c:157
---Type <return> to continue, or q <return> to quit---
#28 0x08082797 in ap_invoke_handler (r=0x83a1538) at config.c:372
#29 0x080d64f8 in ap_process_request (r=0x83a1538) at http_request.c:282
#30 0x080d36db in ap_process_http_connection (c=0x83e1af0) at
http_core.c:190
#31 0x08086769 in ap_run_process_connection (c=0x83e1af0) at
connection.c:43
#32 0x08104f1d in child_main (child_num_arg=<value optimized out>) at 
prefork.c:662
#33 0x08105163 in make_child (s=0x8152c98, slot=0) at prefork.c:702
#34 0x08105f3c in ap_mpm_run (_pconf=0x814a550, plog=0x81a47f8,
s=0x8152c98) at 
prefork.c:978
#35 0x0806cf25 in main (argc=135562568, argv=0x83df910) at main.c:740

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51243&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51243&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51243&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51243&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51243&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51243&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51243&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51243&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51243&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51243&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51243&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51243&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51243&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51243&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51243&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51243&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51243&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51243&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51243&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51243&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51243&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51243&r=mysqlcfg



Thread (14 messages)

« previous php.bugs (#148416) next »