I have now pushed a fix to the branch in question that fixes all memory leaks in our tests. There is one exception, where one test triggers OpenSSL to cache some ECC information.
There is also a small leak in the options_validate test that was there before - this has to do with the log capture, that uses a log callback. This log callback gets registered with a duplicated string for the filename, but I couldn't really figure out the right place to free this.
I have now pushed a fix to the branch in question that fixes all memory leaks in our tests. There is one exception, where one test triggers OpenSSL to cache some ECC information.
This is probably ok.
There is also a small leak in the options_validate test that was there before - this has to do with the log capture, that uses a log callback. This log callback gets registered with a duplicated string for the filename, but I couldn't really figure out the right place to free this.
Tinytest has a setup/teardown mechanism that could be used to deregister the callback and free the string.
Alternately, it can be deregistered/freed at the end of every test function.
(Or are you having trouble accessing the duplicated string from the tests? If it's static, it can be marked STATIC, and placed in the *_PRIVATE section of the header.)
As I said, the leak was there before. I can definitely try to fix it in any of those ways, but it's likely to be a bit more invasive than just accessing a STATIC.
I have fixed this in the most appropriate way I could figure, by adding a small helper function to cleanly remove the log callback. Hopefully this should all be fine now.
I have fixed this in the most appropriate way I could figure, by adding a small helper function to cleanly remove the log callback. Hopefully this should all be fine now.
Couldn't you just have used mark_logs_temp() and close_temp_logs()?
Thank you, I didn't find those functions when looking for something suitable. The branch is now updated to use those instead.
I would also swap clear_log_messages and close_temp_logs to be sure no messages are sent to the callback function in between those calls (which would then reallocated the messages smartlist, leading to another memory leak). It is unlikely to happen but it is better to be correct now than later IMO.