redis / hiredis

Minimalistic C client for Redis >= 1.2
BSD 3-Clause "New" or "Revised" License
6.27k stars 1.82k forks source link

Redis client crash when the redis server is killed for service failover #187

Closed ghost closed 11 years ago

ghost commented 11 years ago

Hi , Here is the stack trace of the application which uses redis async api for performing queries . It's mostly random but happens when redis-server is killed .we are using libev for polling mechanism

Program terminated with signal 11, Segmentation fault.
#0 0x00007f4ad8015198 in ?? ()
(gdb) bt
#0 0x00007f4ad8015198 in ?? ()
#1 0x00007f4b14661a1d in __redisAsyncHandleConnect
(ac=0x7f4ad8080e60) at async.c:475
#2 __redisAsyncHandleConnect (ac=0x7f4ad8080e60) at async.c:489
#3 redisAsyncHandleRead (ac=0x7f4ad8080e60) at async.c:494
#4 0x00007f4b190c928e in redisLibevReadEvent (loop=0x7f4ad8000e90, watcher=0x7f4ad801ed78, revents=1)
at
/home/release/repo/L_VISP_R0.0.7_A003/VISP/build/x86_64-unknown-linux-
gnu/thirdparty/include/libev.h:23
#5 0x00007f4b19116d98 in ev_invoke_pending (loop=0x7f4ad8000e90) at
src/ev/ev.cpp:3007
#6 0x00007f4b19117cc9 in ev_run (loop=0x7f4ad8000e90, flags=0) at
src/ev/ev.cpp:3407
#7 0x00007f4b1911bac1 in vz::EventLoop::start (this=0x7f4b19378620)
at src/EventLoopEv.cpp:103
#8 0x00007f4b18d8bdb9 in vz::ServiceRunner::process (this=0x12d61a0)
at src/ServiceRunner.cpp:120
#9 0x00007f4b190b68c1 in vz::Thread::startPoint (arg=0x12d61a0) at
src/ThreadPthread.cpp:222
#10 0x00007f4b1a817e9a in start_thread (arg=0x7f4aebdfe700) at
pthread_create.c:308
#11 0x00007f4b17080ccd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#12 0x0000000000000000 in ?? ()
pietern commented 11 years ago

The async hiredis client calls its onConnect function pointer when a connection is made, if it is non-NULL.

Maybe this function pointer is set to garbage in your case, resulting in the segmentation fault.

Can you inspect your core to check if this is the case or not? If it is non-NULL -- but not garbage -- the segmentation fault may be caused by code in your callback.