8000 Segmentation fault with pconnect and multiple multi() calls · Issue #151 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content
Segmentation fault with pconnect and multiple multi() calls #151
Closed
@headzoo

Description

@headzoo

I'm getting a segmentation fault while using persistent connections, and executing thousands of multi...exec calls, sleeping, and repeating. This is essentially the code I'm running:

    $redis = new \Redis();
    $connected = $redis->connect('localhost', 6379);
    $fd = fopen('local_backup.txt', 'w');
    if ($connected) {
        for($i = 0; $i < 5; $i++) {
            $uploads = mysql_unbuffered_query($sql);
            while($upload = mysql_fetch_assoc($uploads)) {
                $data = json_encode($upload);
                $redis->multi(\Redis::PIPELINE)
                    ->zAdd($set_key, $upload['time'], $upload_key)
                    ->set($upload_key, $data)
                    ->exec();
                fwrite($fd, "$data\r\n");
            }
            mysql_free_result($uploads);
            sleep(10);
        }
        fclose($fd);
    }

A work around appears to be using Redis::connect() instead of Redis::pconnect(), but I'd much rather use persistent connections.

Here's a backtrace from gdb:

/opt/php/src/php-5.3.8/main/streams/streams.c(438) : Stream of type 'tcp_socket' 0x21dfb80 (path:(null)) was not closed

Program terminated with signal 11, Segmentation fault.
#0 0x00000000006b1d17 in php_tcp_sockop_connect (stream=0x139eb80, sock=0x0, xparam=0x7fff6d57a400) at /opt/php/src/php-5.3.8/main/streams/xp_socket.c:672

672 sock->socket = php_network_connect_socket_to_host(host, portno,
(gdb) bt
#0 0x00000000006b1d17 in php_tcp_sockop_connect (stream=0x139eb80, sock=0x0, xparam=0x7fff6d57a400) at /opt/php/src/php-5.3.8/main/streams/xp_socket.c:672
#1 0x00000000006b20b7 in php_tcp_sockop_set_option (stream=0x139eb80, option=7, value=0, ptrparam=0x7fff6d57a400)

at /opt/php/src/php-5.3.8/main/streams/xp_socket.c:758

#2 0x000000000069e70e in _php_stream_set_option (stream=0x139eb80, option=7, value=0, ptrparam=0x7fff6d57a400)

at /opt/php/src/php-5.3.8/main/streams/streams.c:1220

#3 0x00000000006afc58 in php_stream_xport_connect (stream=0x139eb80, name=0x16aebd0 "nosql1:6379", namelen=11, asynchronous=0, timeout=0x7fff6d57a550,

error_text=0x7fff6d57a560, error_code=0x7fff6d57a654) at /opt/php/src/php-5.3.8/main/streams/transports.c:243

#4 0x00000000006af5e5 in _php_stream_xport_create (name=0x16aebd0 "nosql1:6379", namelen=11, options=4, flags=2,

persistent_id=0x16af430 "phpredis:nosql1:6379:0.000000", timeout=0x7fff6d57a550, context=0x0, error_string=0x7fff6d57a658, error_code=0x7fff6d57a654,
__php_stream_call_depth=0, __zend_filename=0x7f343f2613a0 "/opt/php/src/php-5.3.8/ext/phpredis/library.c", __zend_lineno=790, __zend_orig_filename=0x0,
__zend_orig_lineno=0) at /opt/php/src/php-5.3.8/main/streams/transports.c:143

#5 0x00007f343f24f083 in redis_sock_connect (redis_sock=0x13866c0) at /opt/php/src/php-5.3.8/ext/phpredis/library.c:786
#6 0x00007f343f24a23f in redis_check_eof (redis_sock=0x13866c0) at /opt/php/src/php-5.3.8/ext/phpredis/library.c:59
#7 0x00007f343f24fe5a in redis_sock_write (redis_sock=0x13866c0,

cmd=0x16c48a0 "*4\r\n$4\r\nZADD\r\n$22\r\nBrowse::Viewed::Videos\r\n$10\r\n1.00000000\r\n$39\r\nBrowse::Viewed::Videos::Upload::ABD1967\r\n*3\r\n$3\r\nSET\r\n$39\r\nBrowse::Viewed::Videos::Upload::ABD1967\r\n$421\r\n{\"codename\":\"ABD1967\",\"member"..., sz=594)
at /opt/php/src/php-5.3.8/ext/phpredis/library.c:1084

#8 0x00007f343f245f9e in zim_Redis_exec (ht=0, return_value=0x16aeaa0, return_value_ptr=0x0, this_ptr=0x16ae970, return_value_used=1)

at /opt/php/src/php-5.3.8/ext/phpredis/redis.c:4831

#9 0x0000000000747daf in zend_do_fcall_common_helper_SPEC (execute_data=0x7f343e56b530) at /opt/php/src/php-5.3.8/Zend/zend_vm_execute.h:320
#10 0x000000000074858f in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=0x7f343e56b530) at /opt/php/src/php-5.3.8/Zend/zend_vm_execute.h:425
#11 0x0000000000747087 in execute (op_array=0x1662e88) at /opt/php/src/php-5.3.8/Zend/zend_vm_execute.h:107
#12 0x0000000000707fe9 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /opt/php/src/php-5.3.8/Zend/zend.c:1308
#13 0x000000000067e9b6 in php_execute_script (primary_file=0x7fff6d57ce50) at /opt/php/src/php-5.3.8/main/main.c:2299
#14 0x000000000080b176 in main (argc=3, argv=0x7fff6d57d098) at /opt/php/src/php-5.3.8/sapi/cli/php_cli.c:1188

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0