Page 1 of 1

Debugging a malloc double free

Posted: Tue Feb 26, 2019 1:09 pm
by andras
Hello!

I recently added a lot of extra https calls and I see this error sometimes. I am using luasec to make the calls.

Code: Select all

thread.newThread	lib/webapi.lua
filesystem.newFileData	lib/webapi.lua
filesystem.newFile	lib/webapi.lua
love(78342,0x70000473f000) malloc: *** error for object 0x7fa822e31210: double free
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
The first three lines are logged by my allocation tracker and shows that love.thread.newThread was called by the webapi library prior to the crash. This is the small webapi lib used to make the async https calls. https://github.com/Ulydev/wapi/blob/master/webapi.lua

Can this be related to misusing LOVE threads or does it look like an issue with luasec? How can I narrow down the issue?

Thanks,
Andras

Re: Debugging a malloc double free

Posted: Tue Feb 26, 2019 2:46 pm
by keharriso
I might be able to help, but I'd need a runnable test case to replicate your error. Maybe add a minimal .love file to help out?

Re: Debugging a malloc double free

Posted: Thu Feb 28, 2019 1:36 pm
by andras
I couldn't get a test case working because getting love2d import luasec is such a pain, but I dumbed down webapi.lua to use a single thread and queue up the request. I suspect that luasec (or openssl itself) is not thread-safe, Google kinda confirms this https://github.com/brunoos/luasec/issues/66. Thanks for the help, I'm moving on.