You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mimalloc v3.3.0 / v3.3.1 fails on Windows ARM 64 #1277
Without a stack trace it is difficult to say what is causing this. Is there a trace that I missed?
Maybe you can you try to compile mimalloc with -DMI_WIN_INIT_USE_TLS_DLLMAIN=1 ? (there is also a cmake switch with the same name). We switched to a new init/finalize on windows which maybe causes trouble on arm? (but the mimalloc workflow also tests on windows arm and it works, so, just guessing?).
Daan (@daanx) This issue seems to occur when mimalloc is compiled using plain C compiler on Windows ARM platform.
We can workaround this in rust crate by adjusting the build process so Windows ARM also compiles using C++ compiler. When atomic.h is compiled using plain C compiler, it does write operation on readonly memory and fails to "access violation". When the program is compiled using C++ that atomic implementation is not used.
This is the part of code that requires writable memory:
However, in older version this used to work so there is some change. Shouldn't the atomic implementation be fixed regardless? There might be other variants also that fallback into that implementation?
Ah, I already suspected this yesterday but I didn't get around to it -- great to see you confirmed the issue.
I am a bit torn -- the recommendation is really to use C++ compilation with MSVC on Windows as it just doesn't support the C standard well. The whole C atomics layer for atomics with MSVC in C mode was intended to be temporary... :-)
I see though that nowadays there are new __iso_volatile_load/store primitives that do emit load_acquire/store_release for MSVC so I think I will revise the layer with those instead. TBC.
I updated the MSVC C compilation wrapper using both the new(ish) __iso_volatile_load/store and more optimal arm instructions for load_acquire and store_release. Also added #warning directives for any new platforms so we no longer silently use (wrong) compare_and_swap instructions for readonly memory. Can you try this with the latest dev3 branch ?
Is it still the recommendation to use C++ compilation with MSVC on windows even after these fixes implemented? I'm wondering if this PR should be merged: purpleprotocol/mimalloc_rust#160
I just re-run the GitComet test suite here with latest changes from dev3 branch without any other changes and tests are green. ✔️
Great!
Is it still the recommendation to use C++ compilation with MSVC on windows even after these fixes implemented? I'm wondering if this PR should be merged: purpleprotocol/mimalloc_rust#160
Well, technically msvc nowadays supports C11 and C17 -- but atomics are not quite supported yet (but available behind an experimental flag, I will try this out as well). So, generally I would still recommend using C++ mode.
However, now that the updated C wrapper has special cases for arm systems, the performance should actually be quite good I think, so I think it is fine to compile in C mode with msvc as well. And once msvc supports atomics properly in C11 mode we can switch to that anyways.
(I took a quick look at the PR and it looks good to me; maybe not worth it to add all the extra stuff just to compile with msvc in C++ mode).
Activity
daanx commentedon Apr 21, 2026
Can you try again with v3.3.1 ? maybe the issue has been fixed.
Havunen commentedon Apr 22, 2026
Daan (@daanx) I created my own fork of rust mimalloc (https://github.com/Havunen/mimalloc_rust) and upgraded to 3.3.1 however, the issue persists. Auto-Explore/GitComet#160
[-]mimalloc v3.3.0 fails on Windows ARM 64[/-][+]mimalloc v3.3.0 / v3.3.1 fails on Windows ARM 64[/+]daanx commentedon Apr 22, 2026
Without a stack trace it is difficult to say what is causing this. Is there a trace that I missed?
Maybe you can you try to compile mimalloc with
-DMI_WIN_INIT_USE_TLS_DLLMAIN=1? (there is also a cmake switch with the same name). We switched to a new init/finalize on windows which maybe causes trouble on arm? (but the mimalloc workflow also tests on windows arm and it works, so, just guessing?).Havunen commentedon Apr 23, 2026
I believe I have captured the trace for Windows 11 ARM failure here: https://github.com/Auto-Explore/GitComet/actions/runs/24823983257/job/72655202854?pr=168
Also the full dump file is available for download. Here is summary
Havunen commentedon Apr 23, 2026
DUMP zip: https://github.com/Auto-Explore/GitComet/actions/runs/24823983257/artifacts/6596881602
symbols: https://github.com/Auto-Explore/GitComet/actions/runs/24823983257/artifacts/6596891054
Havunen commentedon Apr 23, 2026
I will now test using -DMI_WIN_INIT_USE_TLS_DLLMAIN=1
Havunen commentedon Apr 23, 2026
enabling
-DMI_WIN_INIT_USE_TLS_DLLMAIN=1did not help. ( Assuming I enabled it correctly here: purpleprotocol/mimalloc_rust@a035c86 )Summary:
Dump: https://github.com/Auto-Explore/GitComet/actions/runs/24824865830/artifacts/6597217147
Symbols: https://github.com/Auto-Explore/GitComet/actions/runs/24824865830/artifacts/6597226071
Daan (@daanx) are these helpful for fixing the issue? Is there anything else I can provide to help fixing this problem
Havunen commentedon Apr 23, 2026
I used AI to find the root cause for this issue. I tested the change in GitComet repository test harness and it now pass.
I opened a PR to fix this issue #1283. The issue seems to come from plain C - compilation on windows arm platform, see the PR
Havunen commentedon Apr 24, 2026
Daan (@daanx) This issue seems to occur when mimalloc is compiled using plain C compiler on Windows ARM platform.
We can workaround this in rust crate by adjusting the build process so Windows ARM also compiles using C++ compiler. When atomic.h is compiled using plain C compiler, it does write operation on readonly memory and fails to "access violation". When the program is compiled using C++ that atomic implementation is not used.
This is the part of code that requires writable memory:
However, in older version this used to work so there is some change. Shouldn't the atomic implementation be fixed regardless? There might be other variants also that fallback into that implementation?
daanx commentedon Apr 24, 2026
Ah, I already suspected this yesterday but I didn't get around to it -- great to see you confirmed the issue.
I am a bit torn -- the recommendation is really to use C++ compilation with MSVC on Windows as it just doesn't support the C standard well. The whole C atomics layer for atomics with MSVC in C mode was intended to be temporary... :-)
I see though that nowadays there are new
__iso_volatile_load/storeprimitives that do emit load_acquire/store_release for MSVC so I think I will revise the layer with those instead. TBC.update MSVC C atomics wrapper to implement loads as readonly and use …
daanx commentedon Apr 24, 2026
I updated the MSVC C compilation wrapper using both the new(ish)
__iso_volatile_load/storeand more optimal arm instructions for load_acquire and store_release. Also added#warningdirectives for any new platforms so we no longer silently use (wrong) compare_and_swap instructions for readonly memory. Can you try this with the latestdev3branch ?Havunen commentedon Apr 24, 2026
I just re-run the GitComet test suite here with latest changes from dev3 branch without any other changes and tests are green. ✔️
Auto-Explore/GitComet#176
Is it still the recommendation to use C++ compilation with MSVC on windows even after these fixes implemented? I'm wondering if this PR should be merged: purpleprotocol/mimalloc_rust#160
daanx commentedon Apr 26, 2026
Great!
Well, technically msvc nowadays supports C11 and C17 -- but atomics are not quite supported yet (but available behind an experimental flag, I will try this out as well). So, generally I would still recommend using C++ mode.
However, now that the updated C wrapper has special cases for arm systems, the performance should actually be quite good I think, so I think it is fine to compile in C mode with msvc as well. And once msvc supports atomics properly in C11 mode we can switch to that anyways.
(I took a quick look at the PR and it looks good to me; maybe not worth it to add all the extra stuff just to compile with msvc in C++ mode).
Havunen commentedon Apr 27, 2026
Any plans for 3.3.2 release? Would be nice to have this fixed
Use C++ to build mimalloc
fix: bump mimalloc to 0.1.51 to fix win-arm64 crash