Crash with v2.1.2
Before upgrading to v2.1.2, my program worked well with v2.0.9. However, after upgrading to v2.1.2, the program crashes when starting up.
I also tried v2.1.0 and v2.1.1, they are good.
I’m using VS2022 with C++ 17 and running on Windows 10 (64-bit). I’ve set the following options:
#ifdef _WIN32
mi_option_enable(mi_option_t::mi_option_verbose);
mi_option_set_enabled(mi_option_e::mi_option_verbose, true);
mi_option_set_enabled(mi_option_e::mi_option_abandoned_page_purge, true);
mi_option_set(mi_option_e::mi_option_purge_delay, 50);
#endif
“If I comment out the lines below, it works well.
// mi_option_enable(mi_option_t::mi_option_verbose);
// mi_option_set_enabled(mi_option_e::mi_option_verbose, true);

Hi @daanx , sorry for bothering, could you please help to check this? It works fine with v2.0.9, 2.1.0, and 2.1.1. Please let me know need I provide more information.
Thanks
Is this using mimalloc redirection?
Is this using mimalloc redirection?
Yes, also override the new delete as the guide.
I think I know what is the cause; thanks for reporting!
The workaround would be to disable verbose, or comment out just the 2 verbose calls in mi_reserve_os_memory_ex (in arena.c).
However, the root cause is troublesome; mimalloc uses vsnprintf before the C runtime is initialized; I thought that was ok but it seems not the case (it might depend on initialization order as I cannot repro) -- this might be due to locale's I guess. Not sure yet how to fix this.. tbc
It's possible that the vsprintf_l versions might work - https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l?view=msvc-170 - where you explicitly provide the locale, so the thinking here is that there is no need to create global variable (from the CRT). Since the source code is available (as part of the SDK / Visual Studio) it can be checked (I'm going to do that myself, and put some findings here)
What might work in this case, if instead of using vsprintf, use the Windows SDK function - e.g. some variant of these - https://learn.microsoft.com/en-us/windows/win32/api/strsafe/nf-strsafe-stringcchvprintf_la