Describe the bug
After timeout is returned to the application for SYNC_COMMIT(2 sec) for HMGET command, the library callsback HMGET when the delayed response comes.
This causes the application to core with SIGSEGV memcpy_sse2_unaligned.
To Reproduce
Application code portion for this logic.
The core line indicates the core @ pCollabMediaUUID->assign(reply.as_array()[0].as_string());
m_redis_client->hmget(sipuricallidhashKey, hmGetFields, [this, &sipuricallidhashKey, &pCollabMediaUUID,
&pIdentity, &pDeviceId]
(cpp_redis::reply& reply) {
LOG_INFO << m_callId << " : "
<< "hmget for sipuricallidhashKey : " << sipuricallidhashKey;
if (reply.is_array() && reply.as_array().size() == 3 &&
reply.as_array()[0].is_string() &&
reply.as_array()[1].is_string() && reply.as_array()[2].is_string()) {
pCollabMediaUUID->assign(reply.as_array()[0].as_string());
pIdentity->assign(reply.as_array()[1].as_string());
pDeviceId->assign(reply.as_array()[2].as_string());
} else {
LOG_ERROR << m_callId << " : "
<< "getClientDetails - FAILED to Read from redis";
}
});
// synchronous commit, timeout
m_redis_client->sync_commit(std::chrono::milliseconds(REDIS_TIMEOUT));
Expected behavior
Expected behavior is not to get the callback for HMGET after the timeout handling is processed.
Screenshots
gdb output of the core file:
(gdb) bt
#0 __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:37
#1 0x00007f7324fa73c2 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_assign(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007f7324fa7b09 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::assign(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x0000000000755464 in RedisClient::<lambda(cpp_redis::reply&)>::operator()(cpp_redis::reply &) const (__closure=0x7f7314009a70,
reply=...) at /builds/edge/signaling-server/source/redisClient.cpp:998
#4 0x0000000000764d5f in std::_Function_handler<void(cpp_redis::reply&), RedisClient::getClientDetails(std::__cxx11::string*, std::__cxx11::string*, std::__cxx11::string*, std::__cxx11::string)::<lambda(cpp_redis::reply&)> >::_M_invoke(const std::_Any_data &, cpp_redis::reply &) (__functor=..., __args#0=...) at /usr/include/c++/5/functional:1871
#5 0x0000000000987d51 in cpp_redis::client::connection_receive_handler(cpp_redis::network::redis_connection&, cpp_redis::reply&) ()
#6 0x00000000009dee89 in cpp_redis::network::redis_connection::tcp_client_receive_handler(cpp_redis::network::tcp_client_iface::read_result const&) ()
#7 0x00000000009df6b8 in std::_Function_handler<void (tacopie::tcp_client::read_result&), cpp_redis::network::tcp_client::async_read(cpp_redis::network::tcp_client_iface::read_request&)::{lambda(tacopie::tcp_client::read_result&)#1}>::_M_invoke(std::_Any_data const&, tacopie::tcp_client::read_result&) ()
#8 0x00000000009e7184 in tacopie::tcp_client::on_read_available(int) ()
#9 0x00000000009e41fd in std::_Function_handler<void (), tacopie::io_service::process_rd_event(int const&, tacopie::io_service::tracked_socket&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
#10 0x00000000009ea8c6 in tacopie::utils::thread_pool::run() ()
#11 0x00007f7324f40c80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#12 0x00007f732541c6ba in start_thread (arg=0x7f7323f7a700) at pthread_create.c:333
#13 0x00007f73246a641d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) fr 3
#3 0x0000000000755464 in RedisClient::<lambda(cpp_redis::reply&)>::operator()(cpp_redis::reply &) const (__closure=0x7f7314009a70,
reply=...) at /builds/edge/signaling-server/source/redisClient.cpp:998
998 /builds/edge/signaling-server/source/redisClient.cpp: No such file or directory.
(gdb) print reply
$1 = (cpp_redis::reply &) @0x7f7323f79cd0: {m_type = cpp_redis::reply::type::array, m_rows = std::vector of length 3, capacity 3 = {{
m_type = cpp_redis::reply::type::bulk_string, m_rows = std::vector of length 0, capacity 0,
m_str_val = "media:75177524-7cdb-4a23-9775-247cdb3a23ee:dev-e2:1-0-0", m_int_val = 140132233556400}, {
m_type = cpp_redis::reply::type::bulk_string, m_rows = std::vector of length 0, capacity 0,
m_str_val = "identity:cfa6dcdc-0ded-487f-a6dc-dc0ded487fb7:dev-e2:1-0-0", m_int_val = 140132233556400}, {
m_type = cpp_redis::reply::type::bulk_string, m_rows = std::vector of length 0, capacity 0,
m_str_val = "device:d76b8e07-f3c9-4fb8-ab8e-07f3c93fb8a0:dev-e2:1-0-0", m_int_val = 140132233556400}}, m_str_val = "",
m_int_val = 3906091140372838712}
(gdb)
Desktop (please complete the following information):