Code: Select all
cargo build --release --target x86_64-pc-windows-gnu
When run on real Windows, it runs fine.
When run under Wine, almost all of the 18 asset loading threads go compute-bound in a Windows spinlock. All 12 CPUs go compute-bound. The program runs very slowly, with but doesn't fail. Eventually, it finishes loading all the assets from disk cache and starts working normally.
So I ran it under winedbg. Waited until it hung, pressed cntl-C, and looked at the situation. Here's what a stuck thread looks like:
Code: Select all
Wine-dbg>bt
Backtrace:
=>0 0x0000017000eba4 in ntdll (+0xeba4) (0x000000003400e0)
1 0x00000170063994 _InterlockedCompareExchange(addr=00000000003400E0, cmp=0000000170082D68, size=0x4, timeout=0000000006EDE638) [Z
:\usr\src\packages\BUILD\include\winnt.h:6630] in ntdll (0x000000003400e0)
2 0x00000170063994 spin_lock(addr=<register RBP not accessible in this frame>, cmp=<register R13 not accessible in this frame>, si
ze=<register RSI not accessible in this frame>, timeout=<register R12 not accessible in this frame>) [Z:\usr\src\packages\BUILD\dlls
\ntdll\sync.c:937] in ntdll (0x000000003400e0)
3 0x00000170063994 RtlWaitOnAddress+0x164(addr=<register RBP not accessible in this frame>, cmp=<register R13 not accessible in th
is frame>, size=<register RSI not accessible in this frame>, timeout=<register R12 not accessible in this frame>) [Z:\usr\src\packag
es\BUILD\dlls\ntdll\sync.c:937] in ntdll (0x000000003400e0)
4 0x00000170063c53 wait_semaphore+0x43(timeout=<internal error>, crit=<internal error>) [Z:\usr\src\packages\BUILD\dlls\ntdll\sync
.c:197] in ntdll (0x00000006ede638)
5 0x00000170063c53 RtlpWaitForCriticalSection+0xa3(crit=<register RBX not accessible in this frame>) [Z:\usr\src\packages\BUILD\dl
ls\ntdll\sync.c:303] in ntdll (0x00000006ede638)
6 0x00000170064761 RtlEnterCriticalSection+0x91(crit=<register RBX not accessible in this frame>) [Z:\usr\src\packages\BUILD\dlls\
ntdll\sync.c:412] in ntdll (0x000000183301b0)
7 0x0000017002bf84 heap_lock+0x15(flags=<internal error>, heap=<internal error>) [Z:\usr\src\packages\BUILD\dlls\ntdll\heap.c:506]
in ntdll (0x000000183301b0)
8 0x0000017002bf84 RtlFreeHeap+0x40c(handle=<register RDI not accessible in this frame>, flags=<register R12 not accessible in thi
s frame>, ptr=<register RBX not accessible in this frame>) [Z:\usr\src\packages\BUILD\dlls\ntdll\heap.c:512] in ntdll (0x00000018330
1b0)
9 0x0000017002d763 RtlFreeHeap+0xe(ptr=<internal error>, flags=<internal error>, handle=<internal error>) [Z:\usr\src\packages\BUI
LD\dlls\ntdll\heap.c:1573] in ntdll (0x000000183301b0)
10 0x0000017002d763 RtlReAllocateHeap+0x423(handle=<register RDI not accessible in this frame>, flags=<register R13 not accessible
in this frame>, ptr=<register RBX not accessible in this frame>, size=<register RSI not accessible in this frame>) [Z:\usr\src\pack
ages\BUILD\dlls\ntdll\heap.c:1700] in ntdll (0x000000183301b0)
11 0x0000014048c115 in sharpview (+0x48c115) (0x00000000000045)
12 0x0000014048d721 in sharpview (+0x48d721) (0x00000000000045)
...
So it's stuck in a spinlock in [Z:\usr\src\packages\BUILD\dlls\ntdll\sync.c:937] in ntdll
See the attachment for the full backtrace.
This seems to be in a heap re-allocation.
This is safe Rust, and the program runs normally except for this stall. So it's probably not heap corruption. It's some kind of locking stall, due to a spinlock being used on something that sometimes is slow. What I suspect here is that Wine has to block when expanding the heap, and RtlFreeHeap assumes that frees are fast and uses spinlocks.
The program is doing extensive graphics using Vulkan, which might somehow be involved.
Wine questions:
- Anyone seen this before?
- How can I get winedbg to find my program's debugger symbols? When the stack backtrace gets back into the Rust code, it doesn't provide any info. The executable does have debugger symbols. I even tried using a debug build, which is even slower, and winedbg didn't find debugging information.
- Where is the source for "Z:\usr\src\packages\BUILD\include\winnt.h:6630". It's not there on my system. I have no \usr\src\packages\BUILD. That seems to refer to a Wine-provided DLL.