nicolasff/phpredis — Issue #92: Segmentation Fault when using Redis::brPop() and spl_autoload_register();
Author: zhangxiao
Created: 2011-12-05 11:16:33+00:00
State: open

The code is very simple. There are 2 source files:

```
/**
* File: A.class.php
* Define class A.
*/
connect('127.0.0.1', '6379');

while (true) {
var_dump($r->brpop('my_queue', 1));
$a = new A();
}
```

When I run test.php script, output is:

```
array(0) {
}
I am a new A
Segmentation fault
```

If I manually require_once() the A.class.php then it's OK.
I am using PHP-5.3.8 and compiled phpredis from trunk. Below is the backtrace from GDB:

```
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fffafdf9000
0x0000003a8c8cb65f in poll () from /lib64/libc.so.6
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000003a8c87c261 in memcpy () from /lib64/libc.so.6
(gdb) bt full
#0 0x0000003a8c87c261 in memcpy () from /lib64/libc.so.6
No symbol table info available.
#1 0x00000000007505fa in xbuf_format_converter (xbuf=0x7fffafd3b7d0, fmt=0xc36f25 "d", ap=0x7fffafd3b810)
at /home/service/source/php-5.3.8/main/spprintf.c:777
__nl =
__dest = 0x7fffafd3b7d0
s = 0x7fffafd3b74e "10"
s_len = 2
free_zcopy = 0
zvp =
zcopy = {value = {lval = 0, dval = 0, str = {val = 0x0, len = 4274326}, ht = 0x0, obj = {handle = 0, handlers = 0x413896}},
refcount__gc = 2694328400, type = 38 '&', is_ref__gc = 43 '+'}
min_width = 0
precision = 0
adjust = RIGHT
pad_char = 32 ' '
prefix_char =
fp_num =
i_num = 10
ui_num =
num_buf = "\b\261ӯ\000\000\000\000\200\270ӯ\377\177\000\000\000\000\000\000\000\000\000\000p\000\000\000\000\000\000\000H:\265\214:\000\000\000g\214@\214:\000\000\000\300\267ӯ\377\177\000\000P\240\330\030\000\000\000\000\026\000\000\000\000\000\000\000\061\000\000\000\000\000\000\000\340'\317\030\000\000\000\000\064\027x", '\000' , "P\204\374\030\000\000\000\000vכ|\000\000\000\000\034\000\000\000\000\000\000\000@\324\370\000\000\000\000\000pm\374\030", '\000' , "_\323vik\362\240Cx\260ӯ\377\177\000\000\t\312z\000\000\000\000\000\b\000\000\000:\000\000\000\034\000\000\000\000\000\000\000p\260ӯ\377\177\000\000\a\000\000\000\000\000\000\000x\260ӯ\377\177\000\000pm\374\030\000\000\000\000 \323\370\000\000\000\000\000\034\000\000\000\000\000\000\000x\260ӯ\377\177\000\000"...
char_buf = "Ȃ"
lconv = 0x0
modifier =
alternate_form =
print_sign =
print_blank = NO
adjust_precision =
adjust_width = NO
is_negative = 0
#2 0x0000000000751904 in vspprintf (pbuf=0x18fc67d0, max_len=0, format=, ap=)
at /home/service/source/php-5.3.8/main/spprintf.c:799
xbuf = {c = 0x5976d6 "!\377\377\377A_\303\017\037", len = 0, a = 78}
#3 0x00000000007b534a in zend_spprintf (message=, max_len=, format=)
at /home/service/source/php-5.3.8/Zend/zend_exceptions.c:532
arg = {{gp_offset = 32, fp_offset = 48, overflow_arg_area = 0x7fffafd3b8f0, reg_save_area = 0x7fffafd3b830}}
len = 5863126
#4 0x0000000000799026 in _convert_to_string (op=0x18fc67d0) at /home/service/source/php-5.3.8/Zend/zend_operators.c:573
lval =
dval =
#5 0x00002b269ea750ef in generic_multiple_args_cmd (ht=, return_value=0x18fc6d70, return_value_ptr=,
---Type to continue, or q to quit---
this_ptr=, return_value_used=, keyword=0x2b269ea92490 "BRPOP", keyword_len=5, min_argc=2,
out_sock=0x7fffafd3ba38, has_timeout=1, all_keys=1) at /home/zhangxiao/downloads/git/phpredis/redis.c:2089
z_args =
z_array =
keys = 0x18fc74a8
cmd =
cmd_len = 32
keys_len = 0x18fc84d8
keys_to_free = 0x18fc7760
i =
j =
argc =
real_argc =
single_array =
timeout =
pos =
redis_sock = 0x18fc7500
#6 0x00002b269ea80291 in zim_Redis_brPop (ht=2, return_value=0x18fc6d70, return_value_ptr=0x0, this_ptr=0x18fc4fb0, return_value_used=1)
at /home/zhangxiao/downloads/git/phpredis/redis.c:1574
redis_sock = 0x18fc7500
#7 0x00000000007ec3f8 in zend_do_fcall_common_helper_SPEC (execute_data=) at /home/service/source/php-5.3.8/Zend/zend_vm_execute.h:320
opline =
should_change_scope = 1 '\001'
#8 0x00000000007c3710 in execute (op_array=0x18fc8910) at /home/service/source/php-5.3.8/Zend/zend_vm_execute.h:107
ret =
execute_data = 0x2b26a0983050
nested = 1 '\001'
original_in_execution = 0 '\000'
#9 0x000000000079d6af in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/service/source/php-5.3.8/Zend/zend.c:1236
files = {{gp_offset = 40, fp_offset = 0, overflow_arg_area = 0x7fffafd3bca0, reg_save_area = 0x7fffafd3bc30}}
i =
file_handle = 0x7fffafd3e170
orig_op_array = 0x0
orig_retval_ptr_ptr = 0x0
#10 0x000000000074b057 in php_execute_script (primary_file=0x7fffafd3e170) at /home/service/source/php-5.3.8/main/main.c:2284
realfile = "/home/zhangxiao/test.php\000php\000\177\000\000\000\000\000\000\000\000\000\000\222\262@\214:", '\000' "\340, \071\265\214:\000\000\000\200\331ӯ\377\177\000\000(\000\000\000\000\000\000\000hB\200\214:\000\000\000\310\064?\233&+\000\000\001\000\000\000\000\000\000\000\230<\315\006\000\000\000\000\002\000\000\000\000\000\000\000`\334\365\000\000\000\000\000`\312\370\000\000\000\000\000@\315\370\000\000\000\000\000\210\336ӯ\377\177\000\000\000\b\364", '\000' , "\005\317@\214:\000\000\000\001", '\000' , "X\205\343\bӄ\346[\000\000\000\000\033\000\000\000hB\200\214:\000\000\000@\310\370\000\000\000\000\000`\312\370\000\000\000\000\000\202)A\214:\000\000\000p-\265\214:\000\000\000\220'\320\030\000\000\000\000"...
__orig_bailout = 0x7fffafd3df50
__bailout = {{__jmpbuf = {16305472, 6622256374731541491, 140736143293448, 0, 140736143293448, 0, 6622256374731565459, 6622126440585886328},
__mask_was_saved = 0, __saved_mask = {__val = {229440404087961, 0, 251465780782, 48, 416231888, 419357728, 8047181, 48, 7, 140736143285760,
1177, 419188608, 140736143285760, 0, 419357600, 0}}}}
prepend_file_p =
---Type to continue, or q to quit---
append_file_p = 0x0
prepend_file = {type = ZEND_HANDLE_FILENAME, filename = 0x0, opened_path = 0x0, handle = {fd = 0, fp = 0x0, stream = {handle = 0x0, isatty = 0,
mmap = {len = 0, pos = 0, map = 0x0, buf = 0x0, old_handle = 0x0, old_closer = 0}, reader = 0, fsizer = 0, closer = 0}},
free_filename = 0 '\000'}
append_file = {type = ZEND_HANDLE_FILENAME, filename = 0x0, opened_path = 0x0, handle = {fd = 0, fp = 0x0, stream = {handle = 0x0, isatty = 0,
mmap = {len = 0, pos = 0, map = 0x0, buf = 0x0, old_handle = 0x0, old_closer = 0}, reader = 0, fsizer = 0, closer = 0}},
free_filename = 0 '\000'}
old_cwd = 0x7fffafd3bcb0 ""
use_heap = 0 '\000'
retval = 0
#11 0x0000000000827ae3 in main (argc=2, argv=0x7fffafd3e3e8) at /home/service/source/php-5.3.8/sapi/cli/php_cli.c:1184
__orig_bailout = 0x0
__bailout = {{__jmpbuf = {110, 6622126440578400887, 16169264, 16168960, 16280416, 15992832, 6622256374731541475, 6622126440573910980},
__mask_was_saved = 0, __saved_mask = {__val = {31, 273085911, 251461144676, 251473701648, 140736143286240, 273085910, 140736143286640,
140736143286664, 251465317000, 0, 47444813378944, 47444813362376, 251490480430, 251465366560, 251490472056, 4294967296}}}}
exit_status = 0
c =
file_handle = {type = ZEND_HANDLE_MAPPED, filename = 0x7fffafd3fc08 "test.php", opened_path = 0x0, handle = {fd = 419191376, fp = 0x18fc5a50,
stream = {handle = 0x18fc5a50, isatty = 0, mmap = {len = 252, pos = 0, map = 0x2b26a0a06000,
buf = 0x2b26a0a06000

, old_handle = 0x18fee020, old_closer = 0x7b2f90 },
reader = 0x7b35a0 , fsizer = 0x7b34e0 , closer = 0x7b3530 }},
free_filename = 0 '\000'}
behavior = 1
reflection_what = 0x0
orig_optind = 1
orig_optarg = 0x0
arg_free =
arg_excp =
script_file =
interactive =
module_started = 1
request_started = 1
lineno = 1
exec_direct = 0x0
exec_run = 0x0
exec_begin = 0x0
exec_end = 0x0
param_error =
hide_argv = 0
ini_entries_len =
```