New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding mimalloc breaks running on Windows 10 #657
Comments
Can't reproduce. Could you provide more details? |
Interesting, I did actually test this on (an admittedly ancient build of) Windows 10 and it certainly worked, insofar as showing models and spinning them around, at least
|
Works fine for me under Wine and a Win10 VM as well. |
I nicked a Toshiba R700 and X40 with Windows version 1909 (build 18363.959) and 2004 (19041.329) respectively, and my GCC 9.3.0 build of the latter commit works there as well.
|
I've downloaded the last snapshot build from https://ci.appveyor.com/project/whitequark/solvespace/build/artifacts So I start Git bisect, building on Windows with Visual studio 2019 Windows 10 Enterprise v1909 build 18363.959 It happens on HP notebook too (build 18363.778) I have domain logons on both devices with some restrictions (can't install/run some programs, etc). |
Since you have Visual Studio, can you attach a debugger and determine the backtrace for your hang? |
I am not so familiar with VS, here is call stack of thread main:
|
Thanks, that's useful. |
here is the callstack with "External code" unwrapped:
|
@nabijaczleweli I have a suspicion of what's happening here. It looks like it hangs in FreeLibrary. This likely happens because a mimalloc heap is created (because of the way C++ thread locals work) for every thread, including those in the Intel integrated graphics driver, and for some reason this causes a deadlock. I think we can fix it by lazily creating a heap. |
@steel-ne Does this help? diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp
index 934220ca..a0809821 100644
--- a/src/platform/platform.cpp
+++ b/src/platform/platform.cpp
@@ -684,20 +684,21 @@ void DebugPrint(const char *fmt, ...) {
//-----------------------------------------------------------------------------
struct MimallocHeap {
- mi_heap_t *heap = mi_heap_new();
-
- MimallocHeap() {
- ssassert(heap != NULL, "out of memory");
- }
+ mi_heap_t *heap = NULL;
~MimallocHeap() {
- mi_heap_destroy(heap);
+ if(heap != NULL)
+ mi_heap_destroy(heap);
}
};
static thread_local MimallocHeap TempArena;
void *AllocTemporary(size_t size) {
+ if(TempArena.heap == NULL) {
+ TempArena.heap = mi_heap_new();
+ ssassert(TempArena.heap != NULL, "out of memory");
+ }
void *ptr = mi_heap_zalloc(TempArena.heap, size);
ssassert(ptr != NULL, "out of memory");
return ptr; |
Yes, it works! |
Interestingly, none of the laptops nor my desktop currently have dedicated GPUs in them; just driver weirdness, I guess? |
Yeah. I think it actually oughtn't crash even the way we wrote it, it might be actually a bug in the driver. But it's good to be defensive here because drivers are full of bugs :) |
System information
SolveSpace version: 3.0~cbac182e
next commit is broken
Operating system: Windows 10
Expected behavior
solvespace runs and shows GUI on windows 10
Actual behavior
solvespace is started and shows no GUI, task is present in task manager
Additional information
commit cbac182 is good
commit c4ca4be is bad
The text was updated successfully, but these errors were encountered: