# PHP 7 Segmentation fault

- Thread: https://externals.io/message/89158
- Original archive: https://news-web.php.net/php.internals/89158
- Started by Frank M. Kromann on 2015-11-11T00:22:08+00:00
- Messages: 16
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #89158 — Frank M. Kromann — 2015-11-11T00:22:08+00:00

URL: https://externals.io/message/89158#89158

Hello Everyone,

I have a large application that segfaults on spl autoload function. I 
have not had the time yet to create a small script that can be used to 
reproduce the error, but it looks to be similar to the one reported for 
PHPUnit.

I'm using the autolaoder script from composer and I have tried 
commenting out code to find the offending class but the problem just 
moves around to the next call to autoload. Here is a backtrace.

#0  zend_mm_alloc_small (size=<optimized out>, bin_num=2, 
heap=0x7ffff0a00040) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:1291
#1  zend_mm_alloc_heap (size=<optimized out>, heap=0x7ffff0a00040) at 
/home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
#2  zend_mm_realloc_heap (heap=0x7ffff0a00040, ptr=0x7ffff0a60590, 
size=<optimized out>, copy_size=24) at 
/home/frank/Source/php-src-7/Zend/zend_alloc.c:1636
#3  0x00000000007e8f4d in zend_add_live_range (start=start@entry=2, 
end=end@entry=57, op_array=<optimized out>, op_array=<optimized out>)
     at /home/frank/Source/php-src-7/Zend/zend_compile.c:582
#4  0x00000000007fa275 in zend_add_live_range (op_array=<optimized out>, 
op_array=<optimized out>, end=57, start=<optimized out>)
     at /home/frank/Source/php-src-7/Zend/zend_compile.c:580
#5  zend_compile_switch (ast=ast@entry=0x7ffff0ab7188) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4139
#6  0x00000000007f8778 in zend_compile_stmt (ast=0x7ffff0ab7188) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7087
#7  0x00000000007f9287 in zend_compile_stmt_list 
(ast=ast@entry=0x7ffff0ab6760) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4411
#8  0x00000000007f861e in zend_compile_stmt 
(ast=ast@entry=0x7ffff0ab6760) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7041
#9  0x00000000007fa4b9 in zend_compile_func_decl 
(result=result@entry=0x0, ast=ast@entry=0x7ffff0ab71a0) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4947
#10 0x00000000007f879a in zend_compile_stmt (ast=0x7ffff0ab71a0) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7097
#11 0x00000000007f9287 in zend_compile_stmt_list 
(ast=ast@entry=0x7ffff0ab8388) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4411
#12 0x00000000007f861e in zend_compile_stmt 
(ast=ast@entry=0x7ffff0ab8388) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7041
#13 0x00000000007f7ca2 in zend_compile_class_decl 
(ast=ast@entry=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:5353
#14 0x00000000007f8738 in zend_compile_stmt 
(ast=ast@entry=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7109
#15 0x00000000007fb03a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7015
#16 0x00000000007fb07f in zend_compile_top_stmt (ast=0x7ffff0ab4018) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7010
#17 0x00000000007ce6e7 in compile_file (file_handle=<optimized out>, 
type=<optimized out>) at Zend/zend_language_scanner.l:607
#18 0x0000000000654bde in phar_compile_file (file_handle=<optimized 
out>, type=<optimized out>) at 
/home/frank/Source/php-src-7/ext/phar/phar.c:3311
#19 0x00000000007ce815 in compile_filename (type=2, 
filename=filename@entry=0x7ffff0a14550) at Zend/zend_language_scanner.l:647
#20 0x000000000089c4cf in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29592
#21 0x000000000084d9db in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#22 0x00000000007fefe7 in zend_call_function (fci=0x7ffff0a899e0, 
fci@entry=0x7fffffffa8f0, fci_cache=fci_cache@entry=0x7fffffffa8c0)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
#23 0x000000000082bd54 in zend_call_method (object=0x7ffff0aa38a8, 
obj_ce=<optimized out>, fn_proxy=<optimized out>,
     function_name=0x7ffff0aaf108 
"composer\\autoload\\classloader::loadclass\001", 
function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
     param_count=param_count@entry=1, arg1=0x7ffff0a14430, 
arg2=arg2@entry=0x0) at 
/home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
#24 0x00000000006c1bb4 in zif_spl_autoload_call (execute_data=<optimized 
out>, return_value=<optimized out>) at 
/home/frank/Source/php-src-7/ext/spl/php_spl.c:425
#25 0x00000000007ff080 in zend_call_function 
(fci=fci@entry=0x7fffffffab40, fci_cache=fci_cache@entry=0x7fffffffab10) 
at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
#26 0x00000000007ff8a9 in zend_lookup_class_ex 
(name=name@entry=0x7ffff0a55e80, key=0x7ffff0a70420, 
use_autoload=use_autoload@entry=1)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
#27 0x00000000008003f8 in zend_fetch_class_by_name 
(class_name=0x7ffff0a55e80, key=<optimized out>, 
fetch_type=fetch_type@entry=512)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
#28 0x000000000089dbf1 in ZEND_NEW_SPEC_CONST_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3359
#29 0x000000000084d9db in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#30 0x00000000008a0619 in zend_execute (op_array=<optimized out>, 
return_value=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
#31 0x000000000080e607 in zend_execute_scripts (type=type@entry=8, 
retval=retval@entry=0x0, file_count=file_count@entry=3) at 
/home/frank/Source/php-src-7/Zend/zend.c:1428
#32 0x00000000007a33c0 in php_execute_script 
(primary_file=primary_file@entry=0x7fffffffd070) at 
/home/frank/Source/php-src-7/main/main.c:2471
#33 0x00000000008a243a in do_cli (argc=4, argv=0x116bc60) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
#34 0x0000000000443617 in main (argc=4, argv=0x116bc60) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345

- Frank

---

## #89175 — Dmitry Stogov — 2015-11-11T12:41:48+00:00

URL: https://externals.io/message/89158#89175 · In reply to: #89158

I suppose this is not PHP-7.0, but "master" branch.
PHP-7.0 doesn't have zend_add_live_range().

Please, make "git pull" and then full rebuild, "make clean; make; make
install"

Thanks. Dmitry.



> Hello Everyone,
>
> I have a large application that segfaults on spl autoload function. I have
> not had the time yet to create a small script that can be used to reproduce
> the error, but it looks to be similar to the one reported for PHPUnit.
>
> I'm using the autolaoder script from composer and I have tried commenting
> out code to find the offending class but the problem just moves around to
> the next call to autoload. Here is a backtrace.
>
> #0  zend_mm_alloc_small (size=<optimized out>, bin_num=2,
> heap=0x7ffff0a00040) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:1291
> #1  zend_mm_alloc_heap (size=<optimized out>, heap=0x7ffff0a00040) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
> #2  zend_mm_realloc_heap (heap=0x7ffff0a00040, ptr=0x7ffff0a60590,
> size=<optimized out>, copy_size=24) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:1636
> #3  0x00000000007e8f4d in zend_add_live_range (start=start@entry=2,
> end=end@entry=57, op_array=<optimized out>, op_array=<optimized out>)
>     at /home/frank/Source/php-src-7/Zend/zend_compile.c:582
> #4  0x00000000007fa275 in zend_add_live_range (op_array=<optimized out>,
> op_array=<optimized out>, end=57, start=<optimized out>)
>     at /home/frank/Source/php-src-7/Zend/zend_compile.c:580
> #5  zend_compile_switch (ast=ast@entry=0x7ffff0ab7188) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4139
> #6  0x00000000007f8778 in zend_compile_stmt (ast=0x7ffff0ab7188) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7087
> #7  0x00000000007f9287 in zend_compile_stmt_list (ast=ast@entry=0x7ffff0ab6760)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:4411
> #8  0x00000000007f861e in zend_compile_stmt (ast=ast@entry=0x7ffff0ab6760)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:7041
> #9  0x00000000007fa4b9 in zend_compile_func_decl (result=result@entry=0x0,
> ast=ast@entry=0x7ffff0ab71a0) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4947
> #10 0x00000000007f879a in zend_compile_stmt (ast=0x7ffff0ab71a0) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7097
> #11 0x00000000007f9287 in zend_compile_stmt_list (ast=ast@entry=0x7ffff0ab8388)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:4411
> #12 0x00000000007f861e in zend_compile_stmt (ast=ast@entry=0x7ffff0ab8388)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:7041
> #13 0x00000000007f7ca2 in zend_compile_class_decl (ast=ast@entry=0x7ffff0ab8720)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:5353
> #14 0x00000000007f8738 in zend_compile_stmt (ast=ast@entry=0x7ffff0ab8720)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:7109
> #15 0x00000000007fb03a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7015
> #16 0x00000000007fb07f in zend_compile_top_stmt (ast=0x7ffff0ab4018) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7010
> #17 0x00000000007ce6e7 in compile_file (file_handle=<optimized out>,
> type=<optimized out>) at Zend/zend_language_scanner.l:607
> #18 0x0000000000654bde in phar_compile_file (file_handle=<optimized out>,
> type=<optimized out>) at /home/frank/Source/php-src-7/ext/phar/phar.c:3311
> #19 0x00000000007ce815 in compile_filename (type=2, filename=filename@entry=0x7ffff0a14550)
> at Zend/zend_language_scanner.l:647
> #20 0x000000000089c4cf in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29592
> #21 0x000000000084d9db in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #22 0x00000000007fefe7 in zend_call_function (fci=0x7ffff0a899e0, fci@entry=0x7fffffffa8f0,
> fci_cache=fci_cache@entry=0x7fffffffa8c0)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
> #23 0x000000000082bd54 in zend_call_method (object=0x7ffff0aa38a8,
> obj_ce=<optimized out>, fn_proxy=<optimized out>,
>     function_name=0x7ffff0aaf108
> "composer\\autoload\\classloader::loadclass\001",
> function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
>     param_count=param_count@entry=1, arg1=0x7ffff0a14430, arg2=arg2@entry=0x0)
> at /home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
> #24 0x00000000006c1bb4 in zif_spl_autoload_call (execute_data=<optimized
> out>, return_value=<optimized out>) at
> /home/frank/Source/php-src-7/ext/spl/php_spl.c:425
> #25 0x00000000007ff080 in zend_call_function (fci=fci@entry=0x7fffffffab40,
> fci_cache=fci_cache@entry=0x7fffffffab10) at
> /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
> #26 0x00000000007ff8a9 in zend_lookup_class_ex (name=name@entry=0x7ffff0a55e80,
> key=0x7ffff0a70420, use_autoload=use_autoload@entry=1)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
> #27 0x00000000008003f8 in zend_fetch_class_by_name
> (class_name=0x7ffff0a55e80, key=<optimized out>, fetch_type=fetch_type@entry
> =512)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
> #28 0x000000000089dbf1 in ZEND_NEW_SPEC_CONST_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3359
> #29 0x000000000084d9db in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #30 0x00000000008a0619 in zend_execute (op_array=<optimized out>,
> return_value=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
> #31 0x000000000080e607 in zend_execute_scripts (type=type@entry=8,
> retval=retval@entry=0x0, file_count=file_count@entry=3) at
> /home/frank/Source/php-src-7/Zend/zend.c:1428
> #32 0x00000000007a33c0 in php_execute_script
> (primary_file=primary_file@entry=0x7fffffffd070) at
> /home/frank/Source/php-src-7/main/main.c:2471
> #33 0x00000000008a243a in do_cli (argc=4, argv=0x116bc60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
> #34 0x0000000000443617 in main (argc=4, argv=0x116bc60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345
>
> - Frank

---

## #89180 — Frank M. Kromann — 2015-11-11T19:14:26+00:00

URL: https://externals.io/message/89158#89180 · In reply to: #89175

Hi Dmitry,

Yes this is the master branch. I have previously tested it on the 
PHP-7.0 branch with the same result. I will do that again to verify that 
the problem is the same.

I run vcsclean, buildconf, configure, make at least once a day. I do not 
run the make install as that will break all the sites on my dev box. I'm 
just testing the new binary with a command line script.

I just did all the steps above and the result is still the same. I'll 
try to create a small script that can be used to reproduce the problem, 
but it might be tricky as it seems to have to do with the number of 
autoloaded classes, a problem with my PHP code (although PHP should not 
seg fault in that case).

- Frank



> I suppose this is not PHP-7.0, but "master" branch.
> PHP-7.0 doesn't have zend_add_live_range().
>
> Please, make "git pull" and then full rebuild, "make clean; make; make
> install"
>
> Thanks. Dmitry.
>
> On Wed, Nov 11, 2015 at 3:22 AM, Frank M. Kromann <fmk@php.net
> <mailto:fmk@php.net>> wrote:
>
>     Hello Everyone,
>
>     I have a large application that segfaults on spl autoload function.
>     I have not had the time yet to create a small script that can be
>     used to reproduce the error, but it looks to be similar to the one
>     reported for PHPUnit.
>
>     I'm using the autolaoder script from composer and I have tried
>     commenting out code to find the offending class but the problem just
>     moves around to the next call to autoload. Here is a backtrace.
>
>     #0  zend_mm_alloc_small (size=<optimized out>, bin_num=2,
>     heap=0x7ffff0a00040) at
>     /home/frank/Source/php-src-7/Zend/zend_alloc.c:1291
>     #1  zend_mm_alloc_heap (size=<optimized out>, heap=0x7ffff0a00040)
>     at /home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
>     #2  zend_mm_realloc_heap (heap=0x7ffff0a00040, ptr=0x7ffff0a60590,
>     size=<optimized out>, copy_size=24) at
>     /home/frank/Source/php-src-7/Zend/zend_alloc.c:1636
>     #3  0x00000000007e8f4d in zend_add_live_range (start=start@entry=2,
>     end=end@entry=57, op_array=<optimized out>, op_array=<optimized out>)
>          at /home/frank/Source/php-src-7/Zend/zend_compile.c:582
>     #4  0x00000000007fa275 in zend_add_live_range (op_array=<optimized
>     out>, op_array=<optimized out>, end=57, start=<optimized out>)
>          at /home/frank/Source/php-src-7/Zend/zend_compile.c:580
>     #5  zend_compile_switch (ast=ast@entry=0x7ffff0ab7188) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:4139
>     #6  0x00000000007f8778 in zend_compile_stmt (ast=0x7ffff0ab7188) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:7087
>     #7  0x00000000007f9287 in zend_compile_stmt_list
>     (ast=ast@entry=0x7ffff0ab6760) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:4411
>     #8  0x00000000007f861e in zend_compile_stmt
>     (ast=ast@entry=0x7ffff0ab6760) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:7041
>     #9  0x00000000007fa4b9 in zend_compile_func_decl
>     (result=result@entry=0x0, ast=ast@entry=0x7ffff0ab71a0) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:4947
>     #10 0x00000000007f879a in zend_compile_stmt (ast=0x7ffff0ab71a0) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:7097
>     #11 0x00000000007f9287 in zend_compile_stmt_list
>     (ast=ast@entry=0x7ffff0ab8388) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:4411
>     #12 0x00000000007f861e in zend_compile_stmt
>     (ast=ast@entry=0x7ffff0ab8388) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:7041
>     #13 0x00000000007f7ca2 in zend_compile_class_decl
>     (ast=ast@entry=0x7ffff0ab8720) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:5353
>     #14 0x00000000007f8738 in zend_compile_stmt
>     (ast=ast@entry=0x7ffff0ab8720) at
>     /home/frank/Source/php-src-7/Zend/zend_compile.c:7109
>     #15 0x00000000007fb03a in zend_compile_top_stmt (ast=0x7ffff0ab8720)
>     at /home/frank/Source/php-src-7/Zend/zend_compile.c:7015
>     #16 0x00000000007fb07f in zend_compile_top_stmt (ast=0x7ffff0ab4018)
>     at /home/frank/Source/php-src-7/Zend/zend_compile.c:7010
>     #17 0x00000000007ce6e7 in compile_file (file_handle=<optimized out>,
>     type=<optimized out>) at Zend/zend_language_scanner.l:607
>     #18 0x0000000000654bde in phar_compile_file (file_handle=<optimized
>     out>, type=<optimized out>) at
>     /home/frank/Source/php-src-7/ext/phar/phar.c:3311
>     #19 0x00000000007ce815 in compile_filename (type=2,
>     filename=filename@entry=0x7ffff0a14550) at
>     Zend/zend_language_scanner.l:647
>     #20 0x000000000089c4cf in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at
>     /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29592
>     #21 0x000000000084d9db in execute_ex (ex=<optimized out>) at
>     /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
>     #22 0x00000000007fefe7 in zend_call_function (fci=0x7ffff0a899e0,
>     fci@entry=0x7fffffffa8f0, fci_cache=fci_cache@entry=0x7fffffffa8c0)
>          at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
>     #23 0x000000000082bd54 in zend_call_method (object=0x7ffff0aa38a8,
>     obj_ce=<optimized out>, fn_proxy=<optimized out>,
>          function_name=0x7ffff0aaf108
>     "composer\\autoload\\classloader::loadclass\001",
>     function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
>          param_count=param_count@entry=1, arg1=0x7ffff0a14430,
>     arg2=arg2@entry=0x0) at
>     /home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
>     #24 0x00000000006c1bb4 in zif_spl_autoload_call
>     (execute_data=<optimized out>, return_value=<optimized out>) at
>     /home/frank/Source/php-src-7/ext/spl/php_spl.c:425
>     #25 0x00000000007ff080 in zend_call_function
>     (fci=fci@entry=0x7fffffffab40,
>     fci_cache=fci_cache@entry=0x7fffffffab10) at
>     /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
>     #26 0x00000000007ff8a9 in zend_lookup_class_ex
>     (name=name@entry=0x7ffff0a55e80, key=0x7ffff0a70420,
>     use_autoload=use_autoload@entry=1)
>          at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
>     #27 0x00000000008003f8 in zend_fetch_class_by_name
>     (class_name=0x7ffff0a55e80, key=<optimized out>,
>     fetch_type=fetch_type@entry=512)
>          at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
>     #28 0x000000000089dbf1 in ZEND_NEW_SPEC_CONST_HANDLER () at
>     /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3359
>     #29 0x000000000084d9db in execute_ex (ex=<optimized out>) at
>     /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
>     #30 0x00000000008a0619 in zend_execute (op_array=<optimized out>,
>     return_value=<optimized out>) at
>     /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
>     #31 0x000000000080e607 in zend_execute_scripts (type=type@entry=8,
>     retval=retval@entry=0x0, file_count=file_count@entry=3) at
>     /home/frank/Source/php-src-7/Zend/zend.c:1428
>     #32 0x00000000007a33c0 in php_execute_script
>     (primary_file=primary_file@entry=0x7fffffffd070) at
>     /home/frank/Source/php-src-7/main/main.c:2471
>     #33 0x00000000008a243a in do_cli (argc=4, argv=0x116bc60) at
>     /home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
>     #34 0x0000000000443617 in main (argc=4, argv=0x116bc60) at
>     /home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345
>
>     - Frank

---

## #89181 — Anatol Belski — 2015-11-11T19:34:21+00:00

URL: https://externals.io/message/89158#89181 · In reply to: #89180

Hi Frank,

> -----Original Message-----
> From: Frank M. Kromann [mailto:fmk@php.net]
> Sent: Wednesday, November 11, 2015 8:14 PM
> To: Dmitry Stogov <dmitry@zend.com>
> Cc: PHP Internals <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PHP 7 Segmentation fault
> 
> Hi Dmitry,
> 
> Yes this is the master branch. I have previously tested it on the
> PHP-7.0 branch with the same result. I will do that again to verify that the
> problem is the same.
> 
> I run vcsclean, buildconf, configure, make at least once a day. I do not run the
> make install as that will break all the sites on my dev box. I'm just testing the
> new binary with a command line script.
> 
> I just did all the steps above and the result is still the same. I'll try to create a
> small script that can be used to reproduce the problem, but it might be tricky as
> it seems to have to do with the number of autoloaded classes, a problem with
> my PHP code (although PHP should not seg fault in that case).
> 
I've just checked for zend_add_live_range - it's even not in the current master. Also ` grep -rn _live_range  Zend/` finds nothing in PHP-7.0. Could you please check that you're using up-to-date source tree and the correct branch? It could be pretty much like something in that direction.

Thanks

---

## #89182 — Frank M. Kromann — 2015-11-11T19:38:36+00:00

URL: https://externals.io/message/89158#89182 · In reply to: #89181

Hi Anatol,

Here is what I have

[frank@dev php-src-7]$ git show
commit d1077f7a897d9267a0cad3d64663fd952dd1c6b2
Merge: e88e3f2 a2e59e7
Author: Anatol Belski <ab@php.net>
Date:   Wed Nov 11 16:35:07 2015 +0100

     Merge branch 'PHP-7.0'

     * PHP-7.0:
       fix format macro names in UPGRADING.INTERNALS

[frank@dev php-src-7]$ git status
# On branch master
# Untracked files:

I think that is the latest from git.php.net?

- Frank


> Hi Frank,
>
> > […]
> I've just checked for zend_add_live_range - it's even not in the current master. Also ` grep -rn _live_range  Zend/` finds nothing in PHP-7.0. Could you please check that you're using up-to-date source tree and the correct branch? It could be pretty much like something in that direction.
>
> Thanks

---

## #89183 — Frank M. Kromann — 2015-11-11T19:40:13+00:00

URL: https://externals.io/message/89158#89183 · In reply to: #89182

Hi Anatol,

Sorry, I fogot to include the output of the grep.

[frank@dev php-src-7]$ grep -rn _live_range  Zend/
Zend/zend_opcode.c:83:    op_array->last_live_range = 0;
Zend/zend_compile.h:176:typedef struct _zend_live_range {
Zend/zend_compile.h:179:} zend_live_range;
Zend/zend_compile.h:364:    int last_live_range;
Zend/zend_compile.h:366:    zend_live_range *live_range;
Zend/zend_compile.c:579:static uint32_t 
zend_start_live_range(zend_op_array *op_array, uint32_t start) /* {{{ */
Zend/zend_compile.c:581:    zend_live_range *range;
Zend/zend_compile.c:583:    op_array->last_live_range++;
Zend/zend_compile.c:584:    op_array->live_range = 
erealloc(op_array->live_range, sizeof(zend_live_range) * 
op_array->last_live_range);
Zend/zend_compile.c:585:    range = op_array->live_range + 
op_array->last_live_range - 1;
Zend/zend_compile.c:587:    return op_array->last_live_range - 1;
Zend/zend_compile.c:591:static void zend_end_live_range(zend_op_array 
*op_array, uint32_t offset, uint32_t end) /* {{{ */
Zend/zend_compile.c:593:    zend_live_range *range = 
op_array->live_range + offset;
Zend/zend_compile.c:595:    if (range->start == end && offset == 
op_array->last_live_range - 1) {
Zend/zend_compile.c:596:        op_array->last_live_range--;
Zend/zend_compile.c:619:        info.u.live_range_offset = 
zend_start_live_range(CG(active_op_array), start);
Zend/zend_compile.c:643: zend_end_live_range(CG(active_op_array), 
loop_var->u.live_range_offset, end);
Zend/zend_compile.c:6472:    range = 
zend_start_live_range(CG(active_op_array), 
get_next_op_number(CG(active_op_array)));
Zend/zend_compile.c:6485: zend_end_live_range(CG(active_op_array), 
range, get_next_op_number(CG(active_op_array)));
Zend/zend_compile.c:6807:        uint32_t range = 
zend_start_live_range(CG(active_op_array), rope_init_lineno);
Zend/zend_compile.c:6822: zend_end_live_range(CG(active_op_array), 
range, opline - CG(active_op_array)->opcodes);
Zend/zend_execute.c:2552:    for (i = 0; i < 
EX(func)->op_array.last_live_range; i++) {
Zend/zend_execute.c:2553:        const zend_live_range *range = 
&EX(func)->op_array.live_range[i];


- Frank


> Hi Anatol,
>
> Here is what I have
>
> [frank@dev php-src-7]$ git show
> commit d1077f7a897d9267a0cad3d64663fd952dd1c6b2
> Merge: e88e3f2 a2e59e7
> Author: Anatol Belski <ab@php.net>
> Date:   Wed Nov 11 16:35:07 2015 +0100
>
>     Merge branch 'PHP-7.0'
>
>     * PHP-7.0:
>       fix format macro names in UPGRADING.INTERNALS
>
> [frank@dev php-src-7]$ git status
> # On branch master
> # Untracked files:
>
> I think that is the latest from git.php.net?
>
> - Frank
>
> 
> > […]
>

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com

---

## #89184 — Frank M. Kromann — 2015-11-11T19:51:09+00:00

URL: https://externals.io/message/89158#89184 · In reply to: #89183

Just switched to PHP-7.0 and there is no longer any references to 
_live_range but the problem with the segfault is still there. Here is a 
new backtrace.

#0  zend_mm_alloc_small (size=<optimized out>, bin_num=<optimized out>, 
heap=<optimized out>) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:1291
#1  zend_mm_alloc_heap (size=<optimized out>, heap=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
#2  _emalloc (size=2) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:2442
#3  0x00000000007e724d in _safe_emalloc (nmemb=nmemb@entry=24, 
size=<optimized out>, offset=offset@entry=0) at 
/home/frank/Source/php-src-7/Zend/zend_alloc.c:2510
#4  0x00000000007f0b93 in zend_compile_params 
(ast=ast@entry=0x7ffff0ab7250, 
return_type_ast=return_type_ast@entry=0x0) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4429
#5  0x00000000007fa240 in zend_compile_func_decl 
(result=result@entry=0x0, ast=ast@entry=0x7ffff0ab7668) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4879
#6  0x00000000007f799a in zend_compile_stmt (ast=0x7ffff0ab7668) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7048
#7  0x00000000007f8487 in zend_compile_stmt_list 
(ast=ast@entry=0x7ffff0ab8388) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:4347
#8  0x00000000007f781e in zend_compile_stmt 
(ast=ast@entry=0x7ffff0ab8388) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:6992
#9  0x00000000007f88bf in zend_compile_class_decl 
(ast=ast@entry=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:5289
#10 0x00000000007f7938 in zend_compile_stmt 
(ast=ast@entry=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:7060
#11 0x00000000007fa67a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:6966
#12 0x00000000007fa6bf in zend_compile_top_stmt (ast=0x7ffff0ab4018) at 
/home/frank/Source/php-src-7/Zend/zend_compile.c:6961
#13 0x00000000007cde07 in compile_file (file_handle=<optimized out>, 
type=<optimized out>) at Zend/zend_language_scanner.l:607
#14 0x000000000065434e in phar_compile_file (file_handle=<optimized 
out>, type=<optimized out>) at 
/home/frank/Source/php-src-7/ext/phar/phar.c:3311
#15 0x00000000007cdf35 in compile_filename (type=2, 
filename=filename@entry=0x7ffff0a14550) at Zend/zend_language_scanner.l:647
#16 0x0000000000899a2f in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29114
#17 0x000000000084cecb in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#18 0x00000000007fe607 in zend_call_function (fci=0x7ffff0a89aa0, 
fci@entry=0x7fffffffa8f0, fci_cache=fci_cache@entry=0x7fffffffa8c0)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
#19 0x000000000082b244 in zend_call_method (object=0x7ffff0aa38d8, 
obj_ce=<optimized out>, fn_proxy=<optimized out>,
     function_name=0x7ffff0aaf108 
"composer\\autoload\\classloader::loadclass\001", 
function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
     param_count=param_count@entry=1, arg1=0x7ffff0a14430, 
arg2=arg2@entry=0x0) at 
/home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
#20 0x00000000006c1324 in zif_spl_autoload_call (execute_data=<optimized 
out>, return_value=<optimized out>) at 
/home/frank/Source/php-src-7/ext/spl/php_spl.c:425
#21 0x00000000007fe6a0 in zend_call_function 
(fci=fci@entry=0x7fffffffab40, fci_cache=fci_cache@entry=0x7fffffffab10) 
at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
#22 0x00000000007feec9 in zend_lookup_class_ex 
(name=name@entry=0x7ffff0a55e80, key=0x7ffff0a70420, 
use_autoload=use_autoload@entry=1)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
#23 0x00000000007ffa18 in zend_fetch_class_by_name 
(class_name=0x7ffff0a55e80, key=<optimized out>, 
fetch_type=fetch_type@entry=512)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
#24 0x000000000089af51 in ZEND_NEW_SPEC_CONST_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3354
#25 0x000000000084cecb in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#26 0x000000000089d969 in zend_execute (op_array=<optimized out>, 
return_value=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
#27 0x000000000080db37 in zend_execute_scripts (type=type@entry=8, 
retval=retval@entry=0x0, file_count=file_count@entry=3) at 
/home/frank/Source/php-src-7/Zend/zend.c:1428
#28 0x00000000007a2ae0 in php_execute_script 
(primary_file=primary_file@entry=0x7fffffffd070) at 
/home/frank/Source/php-src-7/main/main.c:2471
#29 0x000000000089f78a in do_cli (argc=4, argv=0x1167c60) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
#30 0x0000000000443467 in main (argc=4, argv=0x1167c60) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345

- Frank


> Hi Anatol,
>
> Sorry, I fogot to include the output of the grep.
>
> [frank@dev php-src-7]$ grep -rn _live_range  Zend/
> Zend/zend_opcode.c:83:    op_array->last_live_range = 0;
> Zend/zend_compile.h:176:typedef struct _zend_live_range {
> Zend/zend_compile.h:179:} zend_live_range;
> Zend/zend_compile.h:364:    int last_live_range;
> Zend/zend_compile.h:366:    zend_live_range *live_range;
> Zend/zend_compile.c:579:static uint32_t 
> zend_start_live_range(zend_op_array *op_array, uint32_t start) /* {{{ */
> Zend/zend_compile.c:581:    zend_live_range *range;
> Zend/zend_compile.c:583:    op_array->last_live_range++;
> Zend/zend_compile.c:584:    op_array->live_range = 
> erealloc(op_array->live_range, sizeof(zend_live_range) * 
> op_array->last_live_range);
> Zend/zend_compile.c:585:    range = op_array->live_range + 
> op_array->last_live_range - 1;
> Zend/zend_compile.c:587:    return op_array->last_live_range - 1;
> Zend/zend_compile.c:591:static void zend_end_live_range(zend_op_array 
> *op_array, uint32_t offset, uint32_t end) /* {{{ */
> Zend/zend_compile.c:593:    zend_live_range *range = 
> op_array->live_range + offset;
> Zend/zend_compile.c:595:    if (range->start == end && offset == 
> op_array->last_live_range - 1) {
> Zend/zend_compile.c:596:        op_array->last_live_range--;
> Zend/zend_compile.c:619:        info.u.live_range_offset = 
> zend_start_live_range(CG(active_op_array), start);
> Zend/zend_compile.c:643: zend_end_live_range(CG(active_op_array), 
> loop_var->u.live_range_offset, end);
> Zend/zend_compile.c:6472:    range = 
> zend_start_live_range(CG(active_op_array), 
> get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6485: zend_end_live_range(CG(active_op_array), 
> range, get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6807:        uint32_t range = 
> zend_start_live_range(CG(active_op_array), rope_init_lineno);
> Zend/zend_compile.c:6822: zend_end_live_range(CG(active_op_array), 
> range, opline - CG(active_op_array)->opcodes);
> Zend/zend_execute.c:2552:    for (i = 0; i < 
> EX(func)->op_array.last_live_range; i++) {
> Zend/zend_execute.c:2553:        const zend_live_range *range = 
> &EX(func)->op_array.live_range[i];
>
>
> - Frank
>
> 
> > […]
>

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com

---

## #89185 — Anatol Belski — 2015-11-11T20:02:47+00:00

URL: https://externals.io/message/89158#89185 · In reply to: #89184

> -----Original Message-----
> From: Frank M. Kromann [mailto:fmk@webbypixel.com]
> Sent: Wednesday, November 11, 2015 8:51 PM
> To: Anatol Belski <anatol.php@belski.net>; 'Dmitry Stogov' <dmitry@zend.com>
> Cc: 'PHP Internals' <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PHP 7 Segmentation fault
> 
> Just switched to PHP-7.0 and there is no longer any references to _live_range
> but the problem with the segfault is still there. Here is a new backtrace.
> 
> #0  zend_mm_alloc_small (size=<optimized out>, bin_num=<optimized out>,
> heap=<optimized out>) at /home/frank/Source/php-src-
> 7/Zend/zend_alloc.c:1291
> #1  zend_mm_alloc_heap (size=<optimized out>, heap=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
> #2  _emalloc (size=2) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:2442
> #3  0x00000000007e724d in _safe_emalloc (nmemb=nmemb@entry=24,
> size=<optimized out>, offset=offset@entry=0) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2510
> #4  0x00000000007f0b93 in zend_compile_params
> (ast=ast@entry=0x7ffff0ab7250,
> return_type_ast=return_type_ast@entry=0x0) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4429
> #5  0x00000000007fa240 in zend_compile_func_decl (result=result@entry=0x0,
> ast=ast@entry=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4879
> #6  0x00000000007f799a in zend_compile_stmt (ast=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7048
> #7  0x00000000007f8487 in zend_compile_stmt_list
> (ast=ast@entry=0x7ffff0ab8388) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4347
> #8  0x00000000007f781e in zend_compile_stmt
> (ast=ast@entry=0x7ffff0ab8388) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6992
> #9  0x00000000007f88bf in zend_compile_class_decl
> (ast=ast@entry=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:5289
> #10 0x00000000007f7938 in zend_compile_stmt
> (ast=ast@entry=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7060
> #11 0x00000000007fa67a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6966
> #12 0x00000000007fa6bf in zend_compile_top_stmt (ast=0x7ffff0ab4018) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6961
> #13 0x00000000007cde07 in compile_file (file_handle=<optimized out>,
> type=<optimized out>) at Zend/zend_language_scanner.l:607
> #14 0x000000000065434e in phar_compile_file (file_handle=<optimized
> out>, type=<optimized out>) at
> /home/frank/Source/php-src-7/ext/phar/phar.c:3311
> #15 0x00000000007cdf35 in compile_filename (type=2,
> filename=filename@entry=0x7ffff0a14550) at
> Zend/zend_language_scanner.l:647
> #16 0x0000000000899a2f in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER ()
> at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29114
> #17 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #18 0x00000000007fe607 in zend_call_function (fci=0x7ffff0a89aa0,
> fci@entry=0x7fffffffa8f0, fci_cache=fci_cache@entry=0x7fffffffa8c0)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
> #19 0x000000000082b244 in zend_call_method (object=0x7ffff0aa38d8,
> obj_ce=<optimized out>, fn_proxy=<optimized out>,
>      function_name=0x7ffff0aaf108
> "composer\\autoload\\classloader::loadclass\001",
> function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
>      param_count=param_count@entry=1, arg1=0x7ffff0a14430,
> arg2=arg2@entry=0x0) at
> /home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
> #20 0x00000000006c1324 in zif_spl_autoload_call (execute_data=<optimized
> out>, return_value=<optimized out>) at
> /home/frank/Source/php-src-7/ext/spl/php_spl.c:425
> #21 0x00000000007fe6a0 in zend_call_function (fci=fci@entry=0x7fffffffab40,
> fci_cache=fci_cache@entry=0x7fffffffab10)
> at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
> #22 0x00000000007feec9 in zend_lookup_class_ex
> (name=name@entry=0x7ffff0a55e80, key=0x7ffff0a70420,
> use_autoload=use_autoload@entry=1)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
> #23 0x00000000007ffa18 in zend_fetch_class_by_name
> (class_name=0x7ffff0a55e80, key=<optimized out>,
> fetch_type=fetch_type@entry=512)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
> #24 0x000000000089af51 in ZEND_NEW_SPEC_CONST_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3354
> #25 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #26 0x000000000089d969 in zend_execute (op_array=<optimized out>,
> return_value=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
> #27 0x000000000080db37 in zend_execute_scripts (type=type@entry=8,
> retval=retval@entry=0x0, file_count=file_count@entry=3) at
> /home/frank/Source/php-src-7/Zend/zend.c:1428
> #28 0x00000000007a2ae0 in php_execute_script
> (primary_file=primary_file@entry=0x7fffffffd070) at
> /home/frank/Source/php-src-7/main/main.c:2471
> #29 0x000000000089f78a in do_cli (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
> #30 0x0000000000443467 in main (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345
> 
Ok, but in master there's no zend_add_live_range() as well, so that is what was strange. Could you please USE_ZEND_ALLOC=0 to collect the BT? 

Thanks

Anatol

---

## #89186 — Dmitry Stogov — 2015-11-11T20:14:37+00:00

URL: https://externals.io/message/89158#89186 · In reply to: #89184

try to run the same script with valgrind.

USE_ZEND_ALLOC=0 valgrind --db-attach=yes php test.php

(it is 10 times slower)

Show the first reported problem.

Thanks. Dmitry.

On Wed, Nov 11, 2015 at 10:51 PM, Frank M. Kromann <fmk@webbypixel.com>
wrote:

> Just switched to PHP-7.0 and there is no longer any references to
> _live_range but the problem with the segfault is still there. Here is a new
> backtrace.
>
> #0  zend_mm_alloc_small (size=<optimized out>, bin_num=<optimized out>,
> heap=<optimized out>) at /home/frank/Source/php-src-7/Zend/zend_alloc.c:1291
> #1  zend_mm_alloc_heap (size=<optimized out>, heap=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
> #2  _emalloc (size=2) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2442
> #3  0x00000000007e724d in _safe_emalloc (nmemb=nmemb@entry=24,
> size=<optimized out>, offset=offset@entry=0) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2510
> #4  0x00000000007f0b93 in zend_compile_params (ast=ast@entry=0x7ffff0ab7250,
> return_type_ast=return_type_ast@entry=0x0) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4429
> #5  0x00000000007fa240 in zend_compile_func_decl (result=result@entry=0x0,
> ast=ast@entry=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4879
> #6  0x00000000007f799a in zend_compile_stmt (ast=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7048
> #7  0x00000000007f8487 in zend_compile_stmt_list (ast=ast@entry=0x7ffff0ab8388)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:4347
> #8  0x00000000007f781e in zend_compile_stmt (ast=ast@entry=0x7ffff0ab8388)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:6992
> #9  0x00000000007f88bf in zend_compile_class_decl (ast=ast@entry=0x7ffff0ab8720)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:5289
> #10 0x00000000007f7938 in zend_compile_stmt (ast=ast@entry=0x7ffff0ab8720)
> at /home/frank/Source/php-src-7/Zend/zend_compile.c:7060
> #11 0x00000000007fa67a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6966
> #12 0x00000000007fa6bf in zend_compile_top_stmt (ast=0x7ffff0ab4018) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6961
> #13 0x00000000007cde07 in compile_file (file_handle=<optimized out>,
> type=<optimized out>) at Zend/zend_language_scanner.l:607
> #14 0x000000000065434e in phar_compile_file (file_handle=<optimized out>,
> type=<optimized out>) at /home/frank/Source/php-src-7/ext/phar/phar.c:3311
> #15 0x00000000007cdf35 in compile_filename (type=2, filename=filename@entry=0x7ffff0a14550)
> at Zend/zend_language_scanner.l:647
> #16 0x0000000000899a2f in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29114
> #17 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #18 0x00000000007fe607 in zend_call_function (fci=0x7ffff0a89aa0, fci@entry=0x7fffffffa8f0,
> fci_cache=fci_cache@entry=0x7fffffffa8c0)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
> #19 0x000000000082b244 in zend_call_method (object=0x7ffff0aa38d8,
> obj_ce=<optimized out>, fn_proxy=<optimized out>,
>     function_name=0x7ffff0aaf108
> "composer\\autoload\\classloader::loadclass\001",
> function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
>     param_count=param_count@entry=1, arg1=0x7ffff0a14430, arg2=arg2@entry=0x0)
> at /home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
> #20 0x00000000006c1324 in zif_spl_autoload_call (execute_data=<optimized
> out>, return_value=<optimized out>) at
> /home/frank/Source/php-src-7/ext/spl/php_spl.c:425
> #21 0x00000000007fe6a0 in zend_call_function (fci=fci@entry=0x7fffffffab40,
> fci_cache=fci_cache@entry=0x7fffffffab10) at
> /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
> #22 0x00000000007feec9 in zend_lookup_class_ex (name=name@entry=0x7ffff0a55e80,
> key=0x7ffff0a70420, use_autoload=use_autoload@entry=1)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
> #23 0x00000000007ffa18 in zend_fetch_class_by_name
> (class_name=0x7ffff0a55e80, key=<optimized out>, fetch_type=fetch_type@entry
> =512)
>     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
> #24 0x000000000089af51 in ZEND_NEW_SPEC_CONST_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3354
> #25 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #26 0x000000000089d969 in zend_execute (op_array=<optimized out>,
> return_value=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
> #27 0x000000000080db37 in zend_execute_scripts (type=type@entry=8,
> retval=retval@entry=0x0, file_count=file_count@entry=3) at
> /home/frank/Source/php-src-7/Zend/zend.c:1428
> #28 0x00000000007a2ae0 in php_execute_script
> (primary_file=primary_file@entry=0x7fffffffd070) at
> /home/frank/Source/php-src-7/main/main.c:2471
> #29 0x000000000089f78a in do_cli (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
> #30 0x0000000000443467 in main (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345
>
> - Frank
>
>
> 
>
> Hi Anatol,
>
> Sorry, I fogot to include the output of the grep.
>
> [frank@dev php-src-7]$ grep -rn _live_range  Zend/
> Zend/zend_opcode.c:83:    op_array->last_live_range = 0;
> Zend/zend_compile.h:176:typedef struct _zend_live_range {
> Zend/zend_compile.h:179:} zend_live_range;
> Zend/zend_compile.h:364:    int last_live_range;
> Zend/zend_compile.h:366:    zend_live_range *live_range;
> Zend/zend_compile.c:579:static uint32_t
> zend_start_live_range(zend_op_array *op_array, uint32_t start) /* {{{ */
> Zend/zend_compile.c:581:    zend_live_range *range;
> Zend/zend_compile.c:583:    op_array->last_live_range++;
> Zend/zend_compile.c:584:    op_array->live_range =
> erealloc(op_array->live_range, sizeof(zend_live_range) *
> op_array->last_live_range);
> Zend/zend_compile.c:585:    range = op_array->live_range +
> op_array->last_live_range - 1;
> Zend/zend_compile.c:587:    return op_array->last_live_range - 1;
> Zend/zend_compile.c:591:static void zend_end_live_range(zend_op_array
> *op_array, uint32_t offset, uint32_t end) /* {{{ */
> Zend/zend_compile.c:593:    zend_live_range *range = op_array->live_range
> + offset;
> Zend/zend_compile.c:595:    if (range->start == end && offset ==
> op_array->last_live_range - 1) {
> Zend/zend_compile.c:596:        op_array->last_live_range--;
> Zend/zend_compile.c:619:        info.u.live_range_offset =
> zend_start_live_range(CG(active_op_array), start);
> Zend/zend_compile.c:643: zend_end_live_range(CG(active_op_array),
> loop_var->u.live_range_offset, end);
> Zend/zend_compile.c:6472:    range =
> zend_start_live_range(CG(active_op_array),
> get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6485: zend_end_live_range(CG(active_op_array), range,
> get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6807:        uint32_t range =
> zend_start_live_range(CG(active_op_array), rope_init_lineno);
> Zend/zend_compile.c:6822: zend_end_live_range(CG(active_op_array), range,
> opline - CG(active_op_array)->opcodes);
> Zend/zend_execute.c:2552:    for (i = 0; i <
> EX(func)->op_array.last_live_range; i++) {
> Zend/zend_execute.c:2553:        const zend_live_range *range =
> &EX(func)->op_array.live_range[i];
>
>
> - Frank
>
> 
>
> Hi Anatol,
>
> Here is what I have
>
> [frank@dev php-src-7]$ git show
> commit d1077f7a897d9267a0cad3d64663fd952dd1c6b2
> Merge: e88e3f2 a2e59e7
> Author: Anatol Belski <ab@php.net> <ab@php.net>
> Date:   Wed Nov 11 16:35:07 2015 +0100
>
>     Merge branch 'PHP-7.0'
>
>     * PHP-7.0:
>       fix format macro names in UPGRADING.INTERNALS
>
> [frank@dev php-src-7]$ git status
> # On branch master
> # Untracked files:
>
> I think that is the latest from git.php.net?
>
> - Frank
>
> 
>
> Hi Frank,
>
> -----Original Message-----
> From: Frank M. Kromann [mailto:fmk@php.net <fmk@php.net>]
> Sent: Wednesday, November 11, 2015 8:14 PM
> To: Dmitry Stogov <dmitry@zend.com> <dmitry@zend.com>
> Cc: PHP Internals <internals@lists.php.net> <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PHP 7 Segmentation fault
>
> Hi Dmitry,
>
> Yes this is the master branch. I have previously tested it on the
> PHP-7.0 branch with the same result. I will do that again to verify that
> the
> problem is the same.
>
> I run vcsclean, buildconf, configure, make at least once a day. I do not
> run the
> make install as that will break all the sites on my dev box. I'm just
> testing the
> new binary with a command line script.
>
> I just did all the steps above and the result is still the same. I'll try
> to create a
> small script that can be used to reproduce the problem, but it might be
> tricky as
> it seems to have to do with the number of autoloaded classes, a problem
> with
> my PHP code (although PHP should not seg fault in that case).
>
> I've just checked for zend_add_live_range - it's even not in the current
> master. Also ` grep -rn _live_range  Zend/` finds nothing in PHP-7.0. Could
> you please check that you're using up-to-date source tree and the correct
> branch? It could be pretty much like something in that direction.
>
> Thanks
>
>
>
>
> --
> Frank M. Kromann, M.Sc.E.E.
> Web by Pixel, Inc.
>
> Phone: +1 949 742 7533
> Fax: +1 949 742 7534
> Cell: +1 949 702 1794
> Denmark: +45 78 79 11 48
>
> Web: http://webbypixel.com

---

## #89187 — Dmitry Stogov — 2015-11-11T20:16:49+00:00

URL: https://externals.io/message/89158#89187 · In reply to: #89185

I added zend_add_live_range() into master a day ago and replaced it with
zend_start_live_range/zend_end_live_range today.

Thanks. Dmitry.

On Wed, Nov 11, 2015 at 11:02 PM, Anatol Belski <anatol.php@belski.net>
wrote:

>
>
> > […]
> dmitry@zend.com>
> > […]
> _live_range
> > […]
> backtrace.
> > […]
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2442
> > […]
> =0x0,
> > […]
> =0x7fffffffab40,
> > […]
> Ok, but in master there's no zend_add_live_range() as well, so that is
> what was strange. Could you please USE_ZEND_ALLOC=0 to collect the BT?
>
> Thanks
>
> Anatol

---

## #89188 — Frank M. Kromann — 2015-11-11T20:16:55+00:00

URL: https://externals.io/message/89158#89188 · In reply to: #89185

Hi Anatol,

That's odd. I switched back to master and the references to 
_live_range() shows up again. I'll try to do a clean checkout and see 
what happens. Still on the PHP-7.0 branch with USE_ZEND_alloc=0 set in 
the environment I get this backtrace.

#0  0x00007ffff4786563 in malloc_consolidate () from /usr/lib64/libc.so.6
#1  0x00007ffff47880b9 in _int_malloc () from /usr/lib64/libc.so.6
#2  0x00007ffff478abaa in calloc () from /usr/lib64/libc.so.6
#3  0x00007ffff7de60cf in _dl_new_object () from /lib64/ld-linux-x86-64.so.2
#4  0x00007ffff7de11cc in _dl_map_object_from_fd () from 
/lib64/ld-linux-x86-64.so.2
#5  0x00007ffff7de3581 in _dl_map_object () from /lib64/ld-linux-x86-64.so.2
#6  0x00007ffff7dee891 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#7  0x00007ffff7dea2f4 in _dl_catch_error () from 
/lib64/ld-linux-x86-64.so.2
#8  0x00007ffff7dee21b in _dl_open () from /lib64/ld-linux-x86-64.so.2
#9  0x00007ffff483a962 in do_dlopen () from /usr/lib64/libc.so.6
#10 0x00007ffff7dea2f4 in _dl_catch_error () from 
/lib64/ld-linux-x86-64.so.2
#11 0x00007ffff483aa22 in __libc_dlopen_mode () from /usr/lib64/libc.so.6
#12 0x00007ffff4813fd5 in init () from /usr/lib64/libc.so.6
#13 0x00007ffff4ad7be0 in pthread_once () from /usr/lib64/libpthread.so.0
#14 0x00007ffff48140ec in backtrace () from /usr/lib64/libc.so.6
#15 0x00007ffff477fe24 in __libc_message () from /usr/lib64/libc.so.6
#16 0x00007ffff47871fd in _int_free () from /usr/lib64/libc.so.6
#17 0x00007ffff4789a50 in _int_realloc () from /usr/lib64/libc.so.6
#18 0x00007ffff478a702 in realloc () from /usr/lib64/libc.so.6
#19 0x000000000083ba45 in virtual_file_ex 
(state=state@entry=0x7fffffff6ed0, path=path@entry=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc",
     verify_path=verify_path@entry=0x0, 
use_realpath=use_realpath@entry=2) at 
/home/frank/Source/php-src-7/Zend/zend_virtual_cwd.c:1361
#20 0x000000000083cb97 in tsrm_realpath (path=path@entry=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc",
     real_path=real_path@entry=0x7fffffff7fe0 
"/var/www/web20.webbypixel.com/vendor/composer/ClassLoader.php") at 
/home/frank/Source/php-src-7/Zend/zend_virtual_cwd.c:1942
#21 0x00000000007a72c0 in php_resolve_path (filename=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc", 
filename_length=57,
     path=0x117f648 
".:../include:../vendor:/var/www/ZendFramework/library:/usr/local/lib/php") 
at /home/frank/Source/php-src-7/main/fopen_wrappers.c:510
#22 0x000000000063805d in phar_find_in_include_path (filename=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc", 
filename_len=57, pphar=0x7fffffffa068)
     at /home/frank/Source/php-src-7/ext/phar/util.c:291
#23 0x00000000007be84e in _php_stream_open_wrapper_ex 
(path=path@entry=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc", 
mode=mode@entry=0xde5883 "rb",
     options=137, opened_path=opened_path@entry=0x7fffffffa630, 
context=context@entry=0x0) at 
/home/frank/Source/php-src-7/main/streams/streams.c:2035
#24 0x00000000007a0648 in php_stream_open_for_zend_ex 
(filename=0x1383028 
"/var/www/web20.webbypixel.com/include/autoload/cCache.inc", 
handle=0x7fffffffa5d0, mode=<optimized out>)
     at /home/frank/Source/php-src-7/main/main.c:1336
#25 0x000000000082a64c in zend_stream_fixup 
(file_handle=file_handle@entry=0x7fffffffa5d0, 
buf=buf@entry=0x7fffffffa290, len=len@entry=0x7fffffffa298)
     at /home/frank/Source/php-src-7/Zend/zend_stream.c:186
#26 0x00000000007cd7b5 in open_file_for_scanning 
(file_handle=file_handle@entry=0x7fffffffa5d0) at 
Zend/zend_language_scanner.l:508
#27 0x00000000007cdbde in compile_file (file_handle=0x7fffffffa5d0, 
type=2) at Zend/zend_language_scanner.l:578
#28 0x000000000065434e in phar_compile_file (file_handle=<optimized 
out>, type=<optimized out>) at 
/home/frank/Source/php-src-7/ext/phar/phar.c:3311
#29 0x00000000007cdf35 in compile_filename (type=2, 
filename=filename@entry=0x7ffff7f4e560) at Zend/zend_language_scanner.l:647
#30 0x0000000000899a2f in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29114
#31 0x000000000084cecb in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#32 0x00000000007fe607 in zend_call_function (fci=0x13a4230, 
fci@entry=0x7fffffffa8d0, fci_cache=fci_cache@entry=0x7fffffffa8a0)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
#33 0x000000000082b244 in zend_call_method (object=0x139ad68, 
obj_ce=<optimized out>, fn_proxy=<optimized out>,
     function_name=0x139bb08 
"composer\\autoload\\classloader::loadclass\001", 
function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0, 
param_count=param_count@entry=1,
     arg1=0x7ffff7f4e440, arg2=arg2@entry=0x0) at 
/home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
#34 0x00000000006c1324 in zif_spl_autoload_call (execute_data=<optimized 
out>, return_value=<optimized out>) at 
/home/frank/Source/php-src-7/ext/spl/php_spl.c:425
#35 0x00000000007fe6a0 in zend_call_function 
(fci=fci@entry=0x7fffffffab20, fci_cache=fci_cache@entry=0x7fffffffaaf0) 
at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
#36 0x00000000007feec9 in zend_lookup_class_ex 
(name=name@entry=0x138ac50, key=0x1391b80, 
use_autoload=use_autoload@entry=1)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
#37 0x00000000007ffa18 in zend_fetch_class_by_name 
(class_name=0x138ac50, key=<optimized out>, fetch_type=fetch_type@entry=512)
     at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
#38 0x000000000089af51 in ZEND_NEW_SPEC_CONST_HANDLER () at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3354
#39 0x000000000084cecb in execute_ex (ex=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
#40 0x000000000089d969 in zend_execute (op_array=<optimized out>, 
return_value=<optimized out>) at 
/home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
#41 0x000000000080db37 in zend_execute_scripts (type=type@entry=8, 
retval=retval@entry=0x0, file_count=file_count@entry=3) at 
/home/frank/Source/php-src-7/Zend/zend.c:1428
#42 0x00000000007a2ae0 in php_execute_script 
(primary_file=primary_file@entry=0x7fffffffd050) at 
/home/frank/Source/php-src-7/main/main.c:2471
#43 0x000000000089f78a in do_cli (argc=4, argv=0x1167ca0) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
#44 0x0000000000443467 in main (argc=4, argv=0x1167ca0) at 
/home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345


- Frank


>
> > […]
> Ok, but in master there's no zend_add_live_range() as well, so that is what was strange. Could you please USE_ZEND_ALLOC=0 to collect the BT?
>
> Thanks
>
> Anatol
>
>

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com

---

## #89189 — Frank M. Kromann — 2015-11-11T20:24:56+00:00

URL: https://externals.io/message/89158#89189 · In reply to: #89187

Hi Dmitry,

Here is the output.

==28336== Conditional jump or move depends on uninitialised value(s)
==28336==    at 0x64EF568: tzload (FSTimeZones.c:794)
==28336==    by 0x64EFBC0: fstzZoneFromData (FSTimeZones.c:1765)
==28336==    by 0x64EA5ED: fbctzTimeZone (FBCTimeZones.c:51)
==28336==    by 0x64EA19A: fbcrhInitWithOptions (FBCRowHandler.c:94)
==28336==    by 0x587D8C: phpfbFetchRow (php_fbsql.c:986)
==28336==    by 0x58A1BB: php_fbsql_fetch_hash.isra.10 (php_fbsql.c:3089)
==28336==    by 0x85B72D: ZEND_DO_ICALL_SPEC_HANDLER (zend_vm_execute.h:586)
==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
==28336==    by 0x89F789: do_cli (php_cli.c:974)
==28336==
==28336==
==28336== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- n
==28336== Invalid read of size 4
==28336==    at 0x89BE3B: i_free_compiled_variables (zend_execute.c:2052)
==28336==    by 0x89BE3B: zend_leave_helper_SPEC (zend_vm_execute.h:470)
==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
==28336==    by 0x89F789: do_cli (php_cli.c:974)
==28336==    by 0x443466: main (php_cli.c:1345)
==28336==  Address 0x1329d150 is 0 bytes inside a block of size 24 free'd
==28336==    at 0x4C2AD17: free (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28336==    by 0x81E095: _zend_hash_del_el_ex (zend_hash.c:958)
==28336==    by 0x81E095: zend_hash_index_del (zend_hash.c:1170)
==28336==    by 0x89BE52: i_free_compiled_variables (zend_execute.c:2055)
==28336==    by 0x89BE52: zend_leave_helper_SPEC (zend_vm_execute.h:470)
==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
==28336==    by 0x89F789: do_cli (php_cli.c:974)
==28336==    by 0x443466: main (php_cli.c:1345)

The first issue is a leak inside the C API for the FrontBase database. 
It's a known issue that is fixed by the vendor but not yet released and 
it does not cause any segfaults on scripts that don't use autoload of 
classes.

- Frank


> I added zend_add_live_range() into master a day ago and replaced it with
> zend_start_live_range/zend_end_live_range today.
>
> Thanks. Dmitry.
>
> On Wed, Nov 11, 2015 at 11:02 PM, Anatol Belski <anatol.php@belski.net>
> wrote:
>
> > […]

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com

---

## #89190 — Frank M. Kromann — 2015-11-11T20:29:25+00:00

URL: https://externals.io/message/89158#89190 · In reply to: #89185

Hi Anatol,

I created a new clone of the repository and I do get the _live_range 
references.

frank@dev Source]$ git clone http://git.php.net/repository/php-src.git 
php-tmp
Cloning into 'php-tmp'...
remote: Counting objects: 640667, done.
remote: Compressing objects: 100% (128774/128774), done.
remote: Total 640667 (delta 512461), reused 638458 (delta 510563)
Receiving objects: 100% (640667/640667), 160.17 MiB | 31.95 MiB/s, done.
Resolving deltas: 100% (512461/512461), done.
[frank@dev Source]$ cd php-tmp/
[frank@dev php-tmp]$ grep -rn _live_range Zend/
Zend/zend_opcode.c:83:    op_array->last_live_range = 0;
Zend/zend_compile.h:176:typedef struct _zend_live_range {
Zend/zend_compile.h:179:} zend_live_range;
Zend/zend_compile.h:364:    int last_live_range;
Zend/zend_compile.h:366:    zend_live_range *live_range;
Zend/zend_compile.c:579:static uint32_t 
zend_start_live_range(zend_op_array *op_array, uint32_t start) /* {{{ */
Zend/zend_compile.c:581:    zend_live_range *range;
Zend/zend_compile.c:583:    op_array->last_live_range++;
Zend/zend_compile.c:584:    op_array->live_range = 
erealloc(op_array->live_range, sizeof(zend_live_range) * 
op_array->last_live_range);
Zend/zend_compile.c:585:    range = op_array->live_range + 
op_array->last_live_range - 1;
Zend/zend_compile.c:587:    return op_array->last_live_range - 1;
Zend/zend_compile.c:591:static void zend_end_live_range(zend_op_array 
*op_array, uint32_t offset, uint32_t end) /* {{{ */
Zend/zend_compile.c:593:    zend_live_range *range = 
op_array->live_range + offset;
Zend/zend_compile.c:595:    if (range->start == end && offset == 
op_array->last_live_range - 1) {
Zend/zend_compile.c:596:        op_array->last_live_range--;
Zend/zend_compile.c:619:        info.u.live_range_offset = 
zend_start_live_range(CG(active_op_array), start);
Zend/zend_compile.c:643: zend_end_live_range(CG(active_op_array), 
loop_var->u.live_range_offset, end);
Zend/zend_compile.c:6472:    range = 
zend_start_live_range(CG(active_op_array), 
get_next_op_number(CG(active_op_array)));
Zend/zend_compile.c:6485: zend_end_live_range(CG(active_op_array), 
range, get_next_op_number(CG(active_op_array)));
Zend/zend_compile.c:6807:        uint32_t range = 
zend_start_live_range(CG(active_op_array), rope_init_lineno);
Zend/zend_compile.c:6822: zend_end_live_range(CG(active_op_array), 
range, opline - CG(active_op_array)->opcodes);
Zend/zend_execute.c:2552:    for (i = 0; i < 
EX(func)->op_array.last_live_range; i++) {
Zend/zend_execute.c:2553:        const zend_live_range *range = 
&EX(func)->op_array.live_range[i];


- Frank


>
> > […]
> Ok, but in master there's no zend_add_live_range() as well, so that is what was strange. Could you please USE_ZEND_ALLOC=0 to collect the BT?
>
> Thanks
>
> Anatol
>
>

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com

---

## #89191 — Anatol Belski — 2015-11-11T20:31:56+00:00

URL: https://externals.io/message/89158#89191 · In reply to: #89190

Hi Frank,

> -----Original Message-----
> From: Frank M. Kromann [mailto:fmk@webbypixel.com]
> Sent: Wednesday, November 11, 2015 9:29 PM
> To: Anatol Belski <anatol.php@belski.net>; 'Dmitry Stogov' <dmitry@zend.com>
> Cc: 'PHP Internals' <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PHP 7 Segmentation fault
> 
> Hi Anatol,
> 
> I created a new clone of the repository and I do get the _live_range references.
> 
> frank@dev Source]$ git clone http://git.php.net/repository/php-src.git
> php-tmp
> Cloning into 'php-tmp'...
> remote: Counting objects: 640667, done.
> remote: Compressing objects: 100% (128774/128774), done.
> remote: Total 640667 (delta 512461), reused 638458 (delta 510563) Receiving
> objects: 100% (640667/640667), 160.17 MiB | 31.95 MiB/s, done.
> Resolving deltas: 100% (512461/512461), done.
> [frank@dev Source]$ cd php-tmp/
> [frank@dev php-tmp]$ grep -rn _live_range Zend/
> Zend/zend_opcode.c:83:    op_array->last_live_range = 0;
> Zend/zend_compile.h:176:typedef struct _zend_live_range {
> Zend/zend_compile.h:179:} zend_live_range;
> Zend/zend_compile.h:364:    int last_live_range;
> Zend/zend_compile.h:366:    zend_live_range *live_range;
> Zend/zend_compile.c:579:static uint32_t zend_start_live_range(zend_op_array
> *op_array, uint32_t start) /* {{{ */
> Zend/zend_compile.c:581:    zend_live_range *range;
> Zend/zend_compile.c:583:    op_array->last_live_range++;
> Zend/zend_compile.c:584:    op_array->live_range =
> erealloc(op_array->live_range, sizeof(zend_live_range) * op_array-
> > […]
> Zend/zend_compile.c:585:    range = op_array->live_range +
> op_array->last_live_range - 1;
> Zend/zend_compile.c:587:    return op_array->last_live_range - 1;
> Zend/zend_compile.c:591:static void zend_end_live_range(zend_op_array
> *op_array, uint32_t offset, uint32_t end) /* {{{ */
> Zend/zend_compile.c:593:    zend_live_range *range =
> op_array->live_range + offset;
> Zend/zend_compile.c:595:    if (range->start == end && offset ==
> op_array->last_live_range - 1) {
> Zend/zend_compile.c:596:        op_array->last_live_range--;
> Zend/zend_compile.c:619:        info.u.live_range_offset =
> zend_start_live_range(CG(active_op_array), start);
> Zend/zend_compile.c:643: zend_end_live_range(CG(active_op_array),
> loop_var->u.live_range_offset, end);
> Zend/zend_compile.c:6472:    range =
> zend_start_live_range(CG(active_op_array),
> get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6485: zend_end_live_range(CG(active_op_array),
> range, get_next_op_number(CG(active_op_array)));
> Zend/zend_compile.c:6807:        uint32_t range =
> zend_start_live_range(CG(active_op_array), rope_init_lineno);
> Zend/zend_compile.c:6822: zend_end_live_range(CG(active_op_array),
> range, opline - CG(active_op_array)->opcodes);
> Zend/zend_execute.c:2552:    for (i = 0; i <
> EX(func)->op_array.last_live_range; i++) {
> Zend/zend_execute.c:2553:        const zend_live_range *range =
> &EX(func)->op_array.live_range[i];

Yeah, sure. Just there is no zend_add_live_range as in your first BT. We just was ensuring you're using the correct and latest source, be it master or PHP-7.0. Thanks for checking.

Regrads

Anatol

---

## #89192 — Dmitry Stogov — 2015-11-11T21:29:55+00:00

URL: https://externals.io/message/89158#89192 · In reply to: #89189

On Wed, Nov 11, 2015 at 11:24 PM, Frank M. Kromann <fmk@webbypixel.com>
wrote:

> Hi Dmitry,
>
> Here is the output.
>
> ==28336== Conditional jump or move depends on uninitialised value(s)
> ==28336==    at 0x64EF568: tzload (FSTimeZones.c:794)
> ==28336==    by 0x64EFBC0: fstzZoneFromData (FSTimeZones.c:1765)
> ==28336==    by 0x64EA5ED: fbctzTimeZone (FBCTimeZones.c:51)
> ==28336==    by 0x64EA19A: fbcrhInitWithOptions (FBCRowHandler.c:94)
> ==28336==    by 0x587D8C: phpfbFetchRow (php_fbsql.c:986)
> ==28336==    by 0x58A1BB: php_fbsql_fetch_hash.isra.10 (php_fbsql.c:3089)
> ==28336==    by 0x85B72D: ZEND_DO_ICALL_SPEC_HANDLER
> (zend_vm_execute.h:586)
> ==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
> ==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
> ==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
> ==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
> ==28336==    by 0x89F789: do_cli (php_cli.c:974)
> ==28336==
> ==28336==
> ==28336== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- n
> ==28336== Invalid read of size 4
> ==28336==    at 0x89BE3B: i_free_compiled_variables (zend_execute.c:2052)
> ==28336==    by 0x89BE3B: zend_leave_helper_SPEC (zend_vm_execute.h:470)
> ==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
> ==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
> ==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
> ==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
> ==28336==    by 0x89F789: do_cli (php_cli.c:974)
> ==28336==    by 0x443466: main (php_cli.c:1345)
> ==28336==  Address 0x1329d150 is 0 bytes inside a block of size 24 free'd
> ==28336==    at 0x4C2AD17: free (in
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==28336==    by 0x81E095: _zend_hash_del_el_ex (zend_hash.c:958)
> ==28336==    by 0x81E095: zend_hash_index_del (zend_hash.c:1170)
> ==28336==    by 0x89BE52: i_free_compiled_variables (zend_execute.c:2055)
> ==28336==    by 0x89BE52: zend_leave_helper_SPEC (zend_vm_execute.h:470)
> ==28336==    by 0x84CECA: execute_ex (zend_vm_execute.h:414)
> ==28336==    by 0x89D968: zend_execute (zend_vm_execute.h:458)
> ==28336==    by 0x80DB36: zend_execute_scripts (zend.c:1428)
> ==28336==    by 0x7A2ADF: php_execute_script (main.c:2471)
> ==28336==    by 0x89F789: do_cli (php_cli.c:974)
> ==28336==    by 0x443466: main (php_cli.c:1345)
>
> The first issue is a leak inside the C API for the FrontBase database.
> It's a known issue that is fixed by the vendor but not yet released and it
> does not cause any segfaults on scripts that don't use autoload of classes.
>

This is use-after-free. most probably, because of wrong reference counting.
This may be caused by a bug in third party extension.
Can you reproduce the failure without them?

Thanks. Dmitry.


>
> - Frank
>
>
> 
>
> I added zend_add_live_range() into master a day ago and replaced it with
> zend_start_live_range/zend_end_live_range today.
>
> Thanks. Dmitry.
>
> On Wed, Nov 11, 2015 at 11:02 PM, Anatol Belski <anatol.php@belski.net> <anatol.php@belski.net>
> wrote:
>
>
> -----Original Message-----
> From: Frank M. Kromann [mailto:fmk@webbypixel.com <fmk@webbypixel.com>]
> Sent: Wednesday, November 11, 2015 8:51 PM
> To: Anatol Belski <anatol.php@belski.net> <anatol.php@belski.net>; 'Dmitry Stogov' <
>
> dmitry@zend.com>
>
> Cc: 'PHP Internals' <internals@lists.php.net> <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PHP 7 Segmentation fault
>
> Just switched to PHP-7.0 and there is no longer any references to
>
> _live_range
>
> but the problem with the segfault is still there. Here is a new
>
> backtrace.
>
> #0  zend_mm_alloc_small (size=<optimized out>, bin_num=<optimized out>,
> heap=<optimized out>) at /home/frank/Source/php-src-
> 7/Zend/zend_alloc.c:1291
> #1  zend_mm_alloc_heap (size=<optimized out>, heap=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:1358
> #2  _emalloc (size=2) at
>
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2442
>
> #3  0x00000000007e724d in _safe_emalloc (nmemb=nmemb@entry=24,
> size=<optimized out>, offset=offset@entry=0) at
> /home/frank/Source/php-src-7/Zend/zend_alloc.c:2510
> #4  0x00000000007f0b93 in zend_compile_params
> (ast=ast@entry=0x7ffff0ab7250,
> return_type_ast=return_type_ast@entry=0x0) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4429
> #5  0x00000000007fa240 in zend_compile_func_decl (result=result@entry
>
> =0x0,
>
> ast=ast@entry=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4879
> #6  0x00000000007f799a in zend_compile_stmt (ast=0x7ffff0ab7668) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7048
> #7  0x00000000007f8487 in zend_compile_stmt_list
> (ast=ast@entry=0x7ffff0ab8388) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:4347
> #8  0x00000000007f781e in zend_compile_stmt
> (ast=ast@entry=0x7ffff0ab8388) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6992
> #9  0x00000000007f88bf in zend_compile_class_decl
> (ast=ast@entry=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:5289
> #10 0x00000000007f7938 in zend_compile_stmt
> (ast=ast@entry=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:7060
> #11 0x00000000007fa67a in zend_compile_top_stmt (ast=0x7ffff0ab8720) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6966
> #12 0x00000000007fa6bf in zend_compile_top_stmt (ast=0x7ffff0ab4018) at
> /home/frank/Source/php-src-7/Zend/zend_compile.c:6961
> #13 0x00000000007cde07 in compile_file (file_handle=<optimized out>,
> type=<optimized out>) at Zend/zend_language_scanner.l:607
> #14 0x000000000065434e in phar_compile_file (file_handle=<optimized
> out>, type=<optimized out>) at
> /home/frank/Source/php-src-7/ext/phar/phar.c:3311
> #15 0x00000000007cdf35 in compile_filename (type=2,
> filename=filename@entry=0x7ffff0a14550) at
> Zend/zend_language_scanner.l:647
> #16 0x0000000000899a2f in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER ()
> at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:29114
> #17 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #18 0x00000000007fe607 in zend_call_function (fci=0x7ffff0a89aa0,
> fci@entry=0x7fffffffa8f0, fci_cache=fci_cache@entry=0x7fffffffa8c0)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:854
> #19 0x000000000082b244 in zend_call_method (object=0x7ffff0aa38d8,
> obj_ce=<optimized out>, fn_proxy=<optimized out>,
>      function_name=0x7ffff0aaf108
> "composer\\autoload\\classloader::loadclass\001",
> function_name_len=<optimized out>, retval_ptr=retval_ptr@entry=0x0,
>      param_count=param_count@entry=1, arg1=0x7ffff0a14430,
> arg2=arg2@entry=0x0) at
> /home/frank/Source/php-src-7/Zend/zend_interfaces.c:104
> #20 0x00000000006c1324 in zif_spl_autoload_call (execute_data=<optimized
> out>, return_value=<optimized out>) at
> /home/frank/Source/php-src-7/ext/spl/php_spl.c:425
> #21 0x00000000007fe6a0 in zend_call_function (fci=fci@entry
>
> =0x7fffffffab40,
>
> fci_cache=fci_cache@entry=0x7fffffffab10)
> at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:873
> #22 0x00000000007feec9 in zend_lookup_class_ex
> (name=name@entry=0x7ffff0a55e80, key=0x7ffff0a70420,
> use_autoload=use_autoload@entry=1)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1036
> #23 0x00000000007ffa18 in zend_fetch_class_by_name
> (class_name=0x7ffff0a55e80, key=<optimized out>,
> fetch_type=fetch_type@entry=512)
>      at /home/frank/Source/php-src-7/Zend/zend_execute_API.c:1383
> #24 0x000000000089af51 in ZEND_NEW_SPEC_CONST_HANDLER () at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:3354
> #25 0x000000000084cecb in execute_ex (ex=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:414
> #26 0x000000000089d969 in zend_execute (op_array=<optimized out>,
> return_value=<optimized out>) at
> /home/frank/Source/php-src-7/Zend/zend_vm_execute.h:458
> #27 0x000000000080db37 in zend_execute_scripts (type=type@entry=8,
> retval=retval@entry=0x0, file_count=file_count@entry=3) at
> /home/frank/Source/php-src-7/Zend/zend.c:1428
> #28 0x00000000007a2ae0 in php_execute_script
> (primary_file=primary_file@entry=0x7fffffffd070) at
> /home/frank/Source/php-src-7/main/main.c:2471
> #29 0x000000000089f78a in do_cli (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:974
> #30 0x0000000000443467 in main (argc=4, argv=0x1167c60) at
> /home/frank/Source/php-src-7/sapi/cli/php_cli.c:1345
>
>
> Ok, but in master there's no zend_add_live_range() as well, so that is
> what was strange. Could you please USE_ZEND_ALLOC=0 to collect the BT?
>
> Thanks
>
> Anatol
>
>
>
>
> --
> Frank M. Kromann, M.Sc.E.E.
> Web by Pixel, Inc.
>
> Phone: +1 949 742 7533
> Fax: +1 949 742 7534
> Cell: +1 949 702 1794
> Denmark: +45 78 79 11 48
>
> Web: http://webbypixel.com

---

## #89193 — Frank M. Kromann — 2015-11-11T23:12:13+00:00

URL: https://externals.io/message/89158#89193 · In reply to: #89192

Hi Dmetry,

Thanks a lot. That was very helpful. I was not able to run the script 
without the database, but I was able to create a small test script 
without the autoloading and narrow it down to one of two funtions in the 
database extension that causes the problem. I\ll do some more debugging 
and fix the problem in the extension.

- Frank


> On Wed, Nov 11, 2015 at 11:24 PM, Frank M. Kromann <fmk@webbypixel.com>
> wrote:
>
> > […]
> This is use-after-free. most probably, because of wrong reference counting.
> This may be caused by a bug in third party extension.
> Can you reproduce the failure without them?
>
> Thanks. Dmitry.
>
>
> > […]

-- 
Frank M. Kromann, M.Sc.E.E.
Web by Pixel, Inc.

Phone: +1 949 742 7533
Fax: +1 949 742 7534
Cell: +1 949 702 1794
Denmark: +45 78 79 11 48

Web: http://webbypixel.com
