Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] mosquitto_lib_cleanup on Windows throws an exception

Hi,

My project is built with the JUCE framework (C++ UI framework) and the following issue is only present on a Windows platform. 

The JUCE-based application starts a mosquitto client, connects to a broker, everything runs smoothly, however the application doesn't close gracefully. mosquitto operations are run by calling `mosquitto_loop` in a loop in a separate thread. I've seen issues about `mosquitto_loop_forever` not being compatible with Windows and my approach seems to be the right one regarding the Windows compatibility. The error / exception is thrown at the `mosquitto_lib_cleanup()` call, in the destructor of the class which has the `mosquitto mosq` struct member. The destructor and the message are as below:

MQTTService::~MQTTService()
{
// this->disconnect();
    this->stopThread(2000);

    // free memory associated with a mosquitto client instance
    if (this->mosq != nullptr)
    {
        mosquitto_destroy(mosq);
    }

    mosquitto_lib_cleanup();
    DBG("MQTTService destructor called");
}

error messages:

Critical error detected c0000374
Exception thrown at 0x00007FF85B88F279 (ntdll.dll) in MQTTGUI.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FF85B8F87F0).

I've tried to debug this error, however the Visual Studio environment doesn't let me see more, trying a memory inspection tool - Dr. Memory didn't work either - Dr. Memory can't find the `main()` function - I suppose this app being written with JUCE makes debugging a bit more cumbersome.

Is this issue a known one? I'm not sure I'm not sure if this is something purely JUCE-related, or me making a mistake somewhere.
All help will be very appreciated!

Best regards,
Antoni

Back to the top