0

Getting seg fault as debugged using Gdb for the following snippet:

ConnectionOptions connection_options;
connection_options.host = "127.0.0.1";  // Required.
connection_options.port = 9001; // Optional. The default port is 6379.

ConnectionPoolOptions pool_options;
pool_options.size = 3;
RedisCluster cluster2(connection_options, pool_options);

cluster2.set("hello_key", "world_value");

The log from gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff58949ae in sw::redis::ConnectionPool::_fetch() ()
   from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
(gdb) bt
0x00007ffff58949ae in sw::redis::ConnectionPool::_fetch() ()
   from /home/workspace_git/mongoose/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
(gdb) bt
#0  0x00007ffff58949ae in sw::redis::ConnectionPool::_fetch() ()
   from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
#1  0x00007ffff5896e76 in sw::redis::ConnectionPool::fetch() ()
   from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
#2  0x00007ffff58a20a1 in sw::redis::SafeConnection::SafeConnection(sw::redis::ConnectionPool&) ()
   from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
#3  0x00007ffff58ac53a in std::unique_ptr<redisReply, sw::redis::ReplyDeleter> sw::redis::RedisCluster::_command<void (*)(sw::redis::Connection&, sw::redis::StringView const&, sw::redis::StringView const&, long long, sw::redis::UpdateType), sw::redis::StringView const&, sw::redis::StringView const&, long, sw::redis::UpdateType&>(void (*)(sw::redis::Connection&, sw::redis::StringView const&, sw::redis::StringView const&, long long, sw::redis::UpdateType), sw::redis::StringView const&, sw::redis::StringView const&, sw::redis::StringView const&, long&&, sw::redis::UpdateType&) ()
   from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1
#4  0x00007ffff58a9015 in sw::redis::RedisCluster::set(sw::redis::StringView const&, sw::redis::StringView const&, std::chrono::duration<long, std::ratio<1l, 1000l> > const&, sw::redis::UpdateType) () from /home/workspace_git/third_party/redis-plus-plus/redis-plus-plus_install/lib/libredis++.so.1

The version of hiredis: 1.0.2.

The version of redis-plus-plus: 1.3.3

Compiled with C++ 11 option.

Am I doing any basic mistake ?

  • The code looks good to me, and I cannot reproduce your problem. Please give complete code that can reproduce the problem (from the call stack, you did some other operations before calling `set`). Also please catch possible exceptions, and show us the error message. – for_stack Feb 23 '22 at 08:12
  • It is difficult to provide the code for reproducing it. But on further debug it is found that the problem is arising from sw/redis++/redis_cluster.hpp:1337. Printing *pool shows memory errors in host and garbage in port. Thus, I guess that ```auto pool = _pool.fetch(key);``` may be the starting point of the problem. – Sayan Mukherjee Feb 23 '22 at 16:00
  • I found that I am able to avoid the issue with ```ConnectionOptions::type as UNIX socket```. But when I do not set anything explicitly, or I set ```TCP```, I am getting the crash. Although this worked, but I need to get this done using ```TCP``` socket only. – Sayan Mukherjee Feb 23 '22 at 16:34
  • If you cannot reproduce the problem with code only related to redis-plus-plus, it might be your application code corrupt the memory. If there's no code to reproduce the problem, I cannot do much to help. Sorry for that. – for_stack Feb 24 '22 at 02:00

0 Answers0