lmms icon indicating copy to clipboard operation
lmms copied to clipboard

MinGW builds from `master` randomly crash on export

Open PhysSong opened this issue 4 years ago • 2 comments

Reported by @qnebra on Discord:

Hmm, this is strange. latest master + #5536 freeze during rendering, and later completly crash.

And now clean master to check.

checked - render normally

And investigated by @DomClark:

MinGW is freeing the thread-local storage holding rpmalloc's heap pointer before rpmalloc_thread_finalize runs.

We use a thread-local object (MemoryManager::ThreadGuard) to call rpmalloc_thread_finalize when the thread exits. Destruction of thread-local variables in different translation units is unsequenced (as far as I can tell, anyway - the specification says that initialisation of them is unsequenced, and destruction is sequenced if initialisation is, but I can't see anything that makes that last condition "if and only if"). That means that the heap pointer can be used after its destruction, which results in undefined behaviour according to the specification.

Undefined behaviour can be absolutely anything, including working properly (what it's been doing so far), or crashing (what it's doing now).

I can't find any other relevant bug reports, and I can't reproduce this on current master. As @DomClark spotted, however, we have some code which causes undefined behaviors, so I decided to open this issue to keep track of this.

PhysSong avatar Dec 28 '20 06:12 PhysSong

Open LMMS (with) empty project. And try to export it.

On Ubuntu:

src/3rdparty/rpmalloc/rpmalloc/rpmalloc/rpmalloc.c:1328: _rpmalloc_span_finalize: Assertion `(span->list_size == span->used_count) && "Memory leak detected"' failed.
Aborted (core dumped)

Also, I believe, these 3rdparty submodules are old tags. rpmalloc @ 80daac0

anytizer avatar Sep 23 '23 19:09 anytizer

Since MemoryManager is removed, does this bug still occur?

Rossmaxx avatar May 09 '24 07:05 Rossmaxx

I'm not sure, but it shouldn't.

PhysSong avatar May 12 '24 06:05 PhysSong