Merged
Merge Request #23 · created by Peter M. Groen


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.


From pgroen/fix/ab257161_investigate into master

Merged by Peter M. Groen

Source branch has been removed
1 participants