Merged
Merge Request #23
·
created by
pgroen/fix/ab257161 investigate
When we delete our mqttclient instances (276 instances), sometimes we encounter a SEGFAULT originating in MqttClient::eventHandler. GDB always shows: 0x000055555576b4d5 in operator() (_closure=0x7ffea40023b0) at /source/mqtt-cpp/src/mqttclient.cpp:499. This is the line: principalClient->publishPending(); . principalClient pointer is not null, so the if-statement at 495 passes, but it is not a valid pointer. That is because the destructor already deleted that instance of principalClient (line 83, mprincipalClient.swap(principalClient); ). This is clearly indicated by this output:
(gdb) p m_eventQueue.m_stop
$1 = std::atomic = { true }
That indicates the destructor has already executed line 87.
This is caused by obtaining the classic pointer of m_principalClient at line 421, so principalClient is a reference which isn’t accounted for by the smart-pointer.
-
mentioned in commit 8d8360df92f39f66b9e706beb9fd863c3b8b7cb9
-
Status changed to merged