-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
core dump on calling sdsMakeRoomFor #493
Comments
Do you have example code triggering the error? |
I use pipeline, and when getting reply, core dump occurs. for(i=0; i<5; i++)
{
uint32_t docid = rd->ids(i);
redisContext* rediscon = rc->connect;
string command = "HGET " + key + " mulfield";
int err = redisAppendCommand(rediscon, command.c_str());
}
for(i=0; i<5; i++)
{
uint32_t docid = rd->ids(i);
stringstream ss;
ss<<docid;
string key = ss.str();
redisContext* rediscon = rc->connect;
void *reply1 = NULL;
redisGetReply(rediscon,&reply1); **//core dump**
redisReply *reply = (redisReply*)reply1;
if (reply == NULL && rediscon->err != 0)
{
}
if(reply)
freeReplyObject(reply);
} |
I have only one connenction. I also have a detecting thread to rebuild the connenction when it is closed. bool RedisConnectPool::detectConnects()
{
bool bPingRet = true;
for (size_t i=0; i<m_connects.size(); i++)
{
redisContext *tempRedisConn = m_connects[i].connect;
if (NULL == tempRedisConn)
{
bPingRet = false;
break;
}
string command = "PING";
redisReply *reply = (redisReply*)redisCommand(tempRedisConn, command.c_str());
if (reply == NULL && tempRedisConn->err != 0)
{
bPingRet = false;
break;
}
if (reply && reply->type == REDIS_REPLY_STATUS)
{
string strRet = reply->str;
if (strRet.find("PONG") != string::npos)
{
freeReplyObject(reply);
continue;
}
}
bPingRet = false;
freeReplyObject(reply);
break;
}
return bPingRet;
} |
After I close the detecting thread, the coredump does not occur now. I also refer to your reply in #447 A already broken pointer is passed, making it fail in completely unpredictable ways |
Wait, are you using a single hiredis context in multiple threads? |
Yes, I init a connect pool. The processing thread get one connect for pool to use and the detecting thread check every connect in pool if it is useable.. |
I'm also seeing this. I'm not using threads. In my use-case, I start with the redis service down (or I start it up and then take it down while my app is running). I was testing that my app gracefully handles the case where redis become unavailable. I test for redis availability by attempting to send PING's to redis.
The "command" is "PING" My code gets in here 3x, attempting to send the PING and then it seg faults in that same sds function. |
Maybe we're doing something wrong. Are we allowed to keep calling redisAsyncCommand (which seems to append subsequent commands to the output buffer) before we get a reply? |
FYI-- this is the same issue as: #460 |
@dagostinelli OK since this is happening without threading, I'm more inclined to believe that it might actually be a bug in the library. What event library are you using in your case? |
@michael-grunder I'm using libevent |
@michael-grunder If it helps, I'm calling redisAsyncCommand from the callback of an evtimer. |
@dagostinelli can you provide a minimal example to reproduce the issue? I can take a closer look, but likely not before the Christmas days |
We are using hiredis-vip for Redis cluster, this bug is same as hiredis.
|
Going to close this issue but if it's still an issue please provide a minimal example that can trigger the segfault. |
I am getting core dump on realloc of sdsMakeRoomFor. My coredump backtrace is given below:
`Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff67a5700 (LWP 11207)]
0x0000003fc8c32625 in raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0 0x0000003fc8c32625 in raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x0000003fc8c33e05 in abort () at abort.c:92
#2 0x0000003fc8c70537 in __libc_message (do_abort=2, fmt=0x3fc8d588c0 "*** glibc detected *** %s: %s: 0x%s ***\n")
at ../sysdeps/unix/sysv/linux/libc_fatal.c:198
#3 0x0000003fc8c75f4e in malloc_printerr (action=3, str=0x3fc8d5687d "corrupted double-linked list", ptr=,
ar_ptr=) at malloc.c:6350
#4 0x0000003fc8c763d3 in malloc_consolidate (av=0x7ffff0000020) at malloc.c:5216
#5 0x0000003fc8c79c28 in _int_malloc (av=0x7ffff0000020, bytes=) at malloc.c:4415
#6 0x0000003fc8c7bbda in _int_realloc (av=0x7ffff0000020, oldp=0x7ffff0000b60, oldsize=, nb=1312) at malloc.c:5339
#7 0x0000003fc8c7bf78 in __libc_realloc (oldmem=0x7ffff0000b70, bytes=1299) at malloc.c:3823
#8 0x00000000004c7c06 in sdsMakeRoomFor (s=, addlen=) at sds.c:142
#9 0x00000000004c8044 in sdscatlen (s=, t=0x7fffea673080, len=43) at sds.c:241
#10 0x00000000004c5e00 in __redisAppendCommand (c=0x735090, cmd=, len=) at hiredis.c:910
#11 0x00000000004c703c in redisvAppendCommand (c=0x735090, format=, ap=) at hiredis.c:942
#12 0x00000000004c7208 in redisAppendCommand (c=, format=) at hiredis.c:956
#13 0x0000000000446e88 in DataReader::Do (this=0x7ffff6742f50, task=0x7ffff5da3c50) at schsv_dtsvr_V1.0.0/ds/datareader.cpp:106
#14 0x000000000044d1f9 in TaskHandler::Do (p=) at schsv_dtsvr_V1.0.0/ds/task_handler.cpp:41
#15 0x0000003fc9007a51 in start_thread (arg=0x7ffff67a5700) at pthread_create.c:301
#16 0x0000003fc8ce893d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115`
I have worked on the issue for a long time without no progress. Any idea? Thanks!
The text was updated successfully, but these errors were encountered: