Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault when trying to issue a command to closed Unix domain socket #159

Closed
mirkperl opened this issue Apr 8, 2013 · 1 comment
Closed

Comments

@mirkperl
Copy link

mirkperl commented Apr 8, 2013

When using the redisConnectUnix() function to connect to redis via a Unix domain socket, if redis-server exits and you try to issue a command using the context returned from redisConnectUnix() you get a SIGPIPE which is resulting in a segfault, crashing the entire application that uses hiredis.

Here's a backtrace from a simple program that makes a connection to hiredis, sleeps for 5 seconds during which I kill redis in another terminal, then continues to try to issue a DEL command.

(gdb) run
sleeping
done sleeping
Program received signal SIGPIPE, Broken pipe.
0xffffe424 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe424 in __kernel_vsyscall ()
#1 0xb7682a23 in write () from /lib/libc.so.6
#2 0xb7707ea6 in redisBufferWrite () from /usr/lib/libhiredis.so.0.10
#3 0xb7709a1f in redisGetReply () from /usr/lib/libhiredis.so.0.10
#4 0xb7709b0f in redisvCommand () from /usr/lib/libhiredis.so.0.10
#5 0xb7709b4b in redisCommand () from /usr/lib/libhiredis.so.0.10
#6 0x0804863e in main (argc=2, argv=0xbfab6a54) at t.c:25

@pietern
Copy link
Contributor

pietern commented Apr 8, 2013

It's up to the application using hiredis to register a handler for, or ignore, SIGPIPE.

This line shows how to ignore SIGPIPE:

signal(SIGPIPE, SIG_IGN);

@pietern pietern closed this as completed Apr 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants