corrupt heap at MySQL_Connection destructor #19
Comments
Hello. That is not the only problem. I still receive "CORRUPT HEAP: Bad head at 0x3fff2334. Expected 0xabba1234 got 0x3ffe4364", "assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)" Let me investigate further and I'll keep you informed on my research. Just one question, why do you free(server_version) in the destructor of the MySQL_Connection? I think it should be done in the destructor of MySQL_Packet, same way the "free(buffer)", as both variables are of that class and malloc on that class. |
FOUND IT! I suggest 3 things to fix this:
two times you can find this in your code: and it should be: hope this helps. In any case the segmentation fault dissappears and everything works correctly after those 4 changes (the last one is located in two places) |
Thanks for spending time to investigate and propose the fix. Will spend some more time to have a more detailed look. I'd appreciate it if you can help by creating a PR to save me some time. If not, I'll do it anyway. Regards, |
pleasure to help. I've tested these 3 modifications I am suggestion, as well as the other bug fix I've created, and everything works fine. Regards, |
### Release v1.6.1 1. Fix memory management bugs. Check [corrupt heap at MySQL_Connection destructor #19](#19) and [malloc server_version result not correctly handled may lead to memory corruption #20](#20) 2. Add support to SAMD21/SAMD51 boards using [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam) 3. Add support to RP2040 boards using `Seeed RP2040 core` 4. Add `Packages' Patches` for [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam)
### Release v1.6.1 1. Fix memory management bugs. Check [corrupt heap at MySQL_Connection destructor #19](#19) and [malloc server_version result not correctly handled may lead to memory corruption #20](#20) 2. Add support to SAMD21/SAMD51 boards using [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam) 3. Add support to RP2040 boards using `Seeed RP2040 core` 4. Add `Packages' Patches` for [Fab_SAM_Arduino core](https://github.com/qbolsee/ArduinoCore-fab-sam)
The MySQL_Connection destructor performs:
if (server_version) free(server_version);
...but....
the variable "server_version" is not initialized to NULL in the MySQL_Packet constructor.
The variable "server_version" must be initialized to NULL in the MySQL_Packet constructor, exactly as the "buffer" is (see MySQL_Generic_Packet_Impl.h line 74)
This ends up, in some cases:
CORRUPT HEAP: Bad head at 0x3fff2344. Expected 0xabba1234 got 0x3ffe4364
assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)
The text was updated successfully, but these errors were encountered: