Merge branch 'dev' into dev-slice

This commit is contained in:
daan 2022-01-10 16:21:15 -08:00
commit a74c05c6c0
12 changed files with 21 additions and 15 deletions

1
.gitattributes vendored
View File

@ -9,3 +9,4 @@
*.patch binary *.patch binary
*.dll binary *.dll binary
*.lib binary *.lib binary
*.exe binary

View File

@ -337,6 +337,7 @@ if (MI_BUILD_STATIC)
endif() endif()
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY) install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
endif() endif()
# install include files # install include files

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/minject.exe Normal file

Binary file not shown.

BIN
bin/minject32.exe Normal file

Binary file not shown.

View File

@ -447,9 +447,15 @@ struct mi_heap_s {
// Debug // Debug
// ------------------------------------------------------ // ------------------------------------------------------
#if !defined(MI_DEBUG_UNINIT)
#define MI_DEBUG_UNINIT (0xD0) #define MI_DEBUG_UNINIT (0xD0)
#endif
#if !defined(MI_DEBUG_FREED)
#define MI_DEBUG_FREED (0xDF) #define MI_DEBUG_FREED (0xDF)
#endif
#if !defined(MI_DEBUG_PADDING)
#define MI_DEBUG_PADDING (0xDE) #define MI_DEBUG_PADDING (0xDE)
#endif
#if (MI_DEBUG) #if (MI_DEBUG)
// use our own assertion to print without memory allocation // use our own assertion to print without memory allocation

View File

@ -520,14 +520,14 @@ void mi_process_init(void) mi_attr_noexcept {
#endif #endif
_mi_verbose_message("secure level: %d\n", MI_SECURE); _mi_verbose_message("secure level: %d\n", MI_SECURE);
mi_thread_init(); mi_thread_init();
#if defined(_WIN32) && !defined(MI_SHARED_LIB) #if defined(_WIN32) && !defined(MI_SHARED_LIB)
/* When building as a static lib the FLS cleanup happens to early for the main thread. // When building as a static lib the FLS cleanup happens to early for the main thread.
* To avoid that set the FLS value for the main thread to NULL; the eventual // To avoid this, set the FLS value for the main thread to NULL so the fls cleanup
* mi_fls_done() execution won't call _mi_thread_done(). // will not call _mi_thread_done on the (still executing) main thread. See issue #508.
* The latter function is later called explicitly from mi_process_done().
* See GitHub issue #508 for more background and explanation. */
FlsSetValue(mi_fls_key, NULL); FlsSetValue(mi_fls_key, NULL);
#endif #endif
mi_stats_reset(); // only call stat reset *after* thread init (or the heap tld == NULL) mi_stats_reset(); // only call stat reset *after* thread init (or the heap tld == NULL)
if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) { if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
@ -557,9 +557,7 @@ static void mi_process_done(void) {
process_done = true; process_done = true;
#if defined(_WIN32) && !defined(MI_SHARED_LIB) #if defined(_WIN32) && !defined(MI_SHARED_LIB)
// Explicitly clean up main thread. See comment in mi_process_init() for reason FlsFree(mi_fls_key); // call thread-done on all threads (except the main thread) to prevent dangling callback pointer if statically linked with a DLL; Issue #208
_mi_thread_done(_mi_heap_default);
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
#endif #endif
#if (MI_DEBUG != 0) || !defined(MI_SHARED_LIB) #if (MI_DEBUG != 0) || !defined(MI_SHARED_LIB)
@ -600,7 +598,7 @@ static void mi_process_done(void) {
mi_process_load(); mi_process_load();
return 0; return 0;
} }
typedef int(*_crt_cb)(void); typedef int(*_mi_crt_callback_t)(void);
#if defined(_M_X64) || defined(_M_ARM64) #if defined(_M_X64) || defined(_M_ARM64)
__pragma(comment(linker, "/include:" "_mi_msvc_initu")) __pragma(comment(linker, "/include:" "_mi_msvc_initu"))
#pragma section(".CRT$XIU", long, read) #pragma section(".CRT$XIU", long, read)
@ -608,7 +606,7 @@ static void mi_process_done(void) {
__pragma(comment(linker, "/include:" "__mi_msvc_initu")) __pragma(comment(linker, "/include:" "__mi_msvc_initu"))
#endif #endif
#pragma data_seg(".CRT$XIU") #pragma data_seg(".CRT$XIU")
extern "C" _crt_cb _mi_msvc_initu[] = { &_mi_process_init }; extern "C" _mi_crt_callback_t _mi_msvc_initu[] = { &_mi_process_init };
#pragma data_seg() #pragma data_seg()
#elif defined(__cplusplus) #elif defined(__cplusplus)

View File

@ -94,7 +94,7 @@ typedef struct mem_region_s {
mi_bitmap_field_t commit; // track if committed per block mi_bitmap_field_t commit; // track if committed per block
mi_bitmap_field_t reset; // track if reset per block mi_bitmap_field_t reset; // track if reset per block
_Atomic(size_t) arena_memid; // if allocated from a (huge page) arena _Atomic(size_t) arena_memid; // if allocated from a (huge page) arena
size_t padding; // round to 8 fields _Atomic(size_t) padding; // round to 8 fields (needs to be atomic for msvc, see issue #508)
} mem_region_t; } mem_region_t;
// The region map // The region map

View File

@ -50,7 +50,7 @@ int main() {
tsan_numa_test(); tsan_numa_test();
strdup_test(); strdup_test();
//test_mt_shutdown(); test_mt_shutdown();
//fail_aslr(); //fail_aslr();
bench_alloc_large(); bench_alloc_large();
mi_stats_print(NULL); mi_stats_print(NULL);
@ -76,7 +76,7 @@ public:
static void various_tests() { static void various_tests() {
atexit(free_p); atexit(free_p);
void* p1 = malloc(78); void* p1 = malloc(78);
void* p2 = mi_malloc_aligned(16, 24); void* p2 = mi_malloc_aligned(24, 16);
free(p1); free(p1);
p1 = malloc(8); p1 = malloc(8);
char* s = mi_strdup("hello\n"); char* s = mi_strdup("hello\n");