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

Coredump at sdscatlen #1249

Closed
mayursankpal opened this issue Feb 1, 2024 · 2 comments
Closed

Coredump at sdscatlen #1249

mayursankpal opened this issue Feb 1, 2024 · 2 comments

Comments

@mayursankpal
Copy link

mayursankpal commented Feb 1, 2024

Hiredis version = 0.11.0
OS = Debian GNU/Linux 11 (bullseye)
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=6d95e1af3a2c082a

Scenario ==> Inserting data into redis DB ...Called from one of the unit test [googletest]
Command ==> "HSET <some_key> state off"

Stack Trace
Program received signal SIGSEGV, Segmentation fault.
__redisAppendCommand (c=0x0,
cmd=0x4daf10 "*4\r\n$4\r\nHSET\r\n$20\r\nsome_key\r\n$5\r\nstate\r\n$3\r\noff\r\n", len=61)
at hiredis.c:1186
1186 newbuf = sdscatlen(c->obuf,cmd,len);
(gdb) bt
#0 __redisAppendCommand (c=0x0,
cmd=0x4daf10 "*4\r\n$4\r\nHSET\r\n$20\r\nsome_key\r\n$5\r\nstate\r\n$3\r\noff\r\n", len=61)
at hiredis.c:1186
#1 0x00007fffff6f461c in redisvAppendCommand (c=0x0, format=, ap=) at hiredis.c:1206
#2 0x00007fffff6f4792 in redisvCommand (c=0x0, format=, ap=ap@entry=0x7ffffffed498) at hiredis.c:1267
#3 0x00007fffff6f4847 in redisCommand (c=,
format=format@entry=0x4dc530 "HSET runtime.status.comms state off") at hiredis.c:1276

@michael-grunder
Copy link
Collaborator

michael-grunder commented Feb 1, 2024

Looks like you aren't making redisConnect is returning a valid context as c=0x0.

So you've got a NULL redisContext making redisContext->obuf just 0 + the offset of that member, which if course is not a valid sds string 😄

I can't help much more than that without a bit of code that reproduces the issue. Fix should be simple though. Just make sure redisConnect is returning a valid pointer and c->err is not set.

@michael-grunder
Copy link
Collaborator

Closing as this doesn't seem to be a bug in hiredis but still happy to answer any other questions you have.

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