add preload check to options initialization
@@ -367,6 +367,10 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
}
#endif
static void mi_option_init(mi_option_desc_t* desc) {
+ #ifndef _WIN32
+ // cannot call getenv() when still initializing the C runtime.
+ if (_mi_preloading()) return;
+ #endif
// Read option value from the environment
char buf[64+1];
mi_strlcpy(buf, "mimalloc_", sizeof(buf));
