Skip to content

Fatal error in GC: SuspendThread failed due to race condition #303

@tobil4sk

Description

@tobil4sk

From: #281 (comment)

It looks like this happens because the thread is deleted by DLLMain
https://github.com/ivmai/bdwgc/blob/2558568aceaf7fc5cc64cf87e244cbcfd7f9bd53/win32_threads.c#L3009

Somehow this happens at the same time as the GC_gcollect call within neko_gc_major() while neko is shutting down, which also tries to access the same thread to suspend it.

Can be reproduced by running this program repeatedly:

function main() {
	final lock = new sys.thread.Lock();
	sys.thread.Thread.create(function() {
		lock.release();
	});
	lock.wait();
}

Here is a minimal sample. For this to reproduce the following conditions must be met:

  • App must contain thread
  • Thread must complete before the main thread
  • DllMain call for detaching thread must be interleaved with a GC_gcollect call in neko_gc_major()

See: bdwgc/bdwgc#704

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions