Piotr Caban (@piotr) commented about dlls/msvcrt/concurrency.c:
void msvcrt_free_scheduler_thread(void) { - Context *context = try_get_current_context(); + ExternalContextBase *context = (ExternalContextBase*)try_get_current_context(); if (!context) return; - call_Context_dtor(context, 1); + if (context->context.vtable != &ExternalContextBase_vtable || + InterlockedDecrement(&context->ref) == 0)
I don't know how it's supposed to work but this code looks incorrect (or at least it's very bad design from C++ point of view). Adding ref-counting to the context is not really an option (because C++ objects are not managing memory used to store class structure). Maybe ThreadScheduler should be responsible for creating/managing contexts, but it looks like we're missing something. I would like to see some tests (even if we can't add it to wine for some reason). I didn't test it myself but I hope to give you some hints after playing with them. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/464#note_5087