mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-21 17:09:06 -07:00
msvcrt: Do not create a separate heap in newer msvcrt versions.
A llvm-mingw built winver.exe with ASan enabled shows below error when exiting the application. This seems to be caused by libc++ using register_onexit_function before ASan has all function hooks in place, therefore allocates memory with plain calloc function. On process exit ASan uses in asan_allocator.cpp/Deallocate the function HeapValidate, which fails if msvcrt does not use the heap returned by GetProcessHeap().
This commit is contained in:
parent
c9a8333c0f
commit
d78cbe84e5
Notes:
Alexandre Julliard
2024-11-11 23:04:47 +01:00
Approved-by: Alexandre Julliard (@julliard) Approved-by: Piotr Caban (@piotr) Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6791
6 changed files with 35 additions and 0 deletions
|
@ -239,6 +239,7 @@ static size_t (__cdecl *p___strncnt)(const char*, size_t);
|
|||
|
||||
static int (__cdecl *p_strcmp)(const char *, const char *);
|
||||
static int (__cdecl *p_strncmp)(const char *, const char *, size_t);
|
||||
static intptr_t (__cdecl *p__get_heap_handle)(void);
|
||||
|
||||
/* make sure we use the correct errno */
|
||||
#undef errno
|
||||
|
@ -282,6 +283,7 @@ static BOOL init(void)
|
|||
|
||||
SET(p_strcmp, "strcmp");
|
||||
SET(p_strncmp, "strncmp");
|
||||
SET(p__get_heap_handle, "_get_heap_handle");
|
||||
|
||||
if(sizeof(void*) == 8) { /* 64-bit initialization */
|
||||
SET(pSpinWait_ctor_yield, "??0?$_SpinWait@$00@details@Concurrency@@QEAA@P6AXXZ@Z");
|
||||
|
@ -1152,6 +1154,11 @@ static void test_strcmp(void)
|
|||
ok( ret == 0, "wrong ret %d\n", ret );
|
||||
}
|
||||
|
||||
static void test__get_heap_handle(void)
|
||||
{
|
||||
ok((HANDLE)p__get_heap_handle() != GetProcessHeap(), "Expected _get_heap_handle() not to return GetProcessHeap()\n");
|
||||
}
|
||||
|
||||
START_TEST(msvcr100)
|
||||
{
|
||||
if (!init())
|
||||
|
@ -1173,4 +1180,5 @@ START_TEST(msvcr100)
|
|||
test_setlocale();
|
||||
test___strncnt();
|
||||
test_strcmp();
|
||||
test__get_heap_handle();
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ static _Context* (__cdecl *p__Context__CurrentContext)(_Context*);
|
|||
|
||||
static int (__cdecl *p_strcmp)(const char *, const char *);
|
||||
static int (__cdecl *p_strncmp)(const char *, const char *, size_t);
|
||||
static intptr_t (__cdecl *p__get_heap_handle)(void);
|
||||
|
||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(module,y)
|
||||
#define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
|
||||
|
@ -89,6 +90,7 @@ static BOOL init(void)
|
|||
|
||||
SET(p_strcmp, "strcmp");
|
||||
SET(p_strncmp, "strncmp");
|
||||
SET(p__get_heap_handle, "_get_heap_handle");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -307,6 +309,11 @@ static void test_strcmp(void)
|
|||
ok( ret == 0, "wrong ret %d\n", ret );
|
||||
}
|
||||
|
||||
static void test__get_heap_handle(void)
|
||||
{
|
||||
ok((HANDLE)p__get_heap_handle() == GetProcessHeap(), "Expected _get_heap_handle() to return GetProcessHeap()\n");
|
||||
}
|
||||
|
||||
START_TEST(msvcr110)
|
||||
{
|
||||
if (!init()) return;
|
||||
|
@ -315,4 +322,5 @@ START_TEST(msvcr110)
|
|||
test___strncnt();
|
||||
test_CurrentContext();
|
||||
test_strcmp();
|
||||
test__get_heap_handle();
|
||||
}
|
||||
|
|
|
@ -829,13 +829,19 @@ int CDECL wmemcpy_s(wchar_t *dest, size_t numberOfElements,
|
|||
|
||||
BOOL msvcrt_init_heap(void)
|
||||
{
|
||||
#if _MSVCR_VER <= 100
|
||||
heap = HeapCreate(0, 0, 0);
|
||||
#else
|
||||
heap = GetProcessHeap();
|
||||
#endif
|
||||
return heap != NULL;
|
||||
}
|
||||
|
||||
void msvcrt_destroy_heap(void)
|
||||
{
|
||||
#if _MSVCR_VER <= 100
|
||||
HeapDestroy(heap);
|
||||
#endif
|
||||
if(sb_heap)
|
||||
HeapDestroy(sb_heap);
|
||||
}
|
||||
|
|
|
@ -523,10 +523,16 @@ static void test_calloc(void)
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
static void test__get_heap_handle(void)
|
||||
{
|
||||
ok((HANDLE)_get_heap_handle() != GetProcessHeap(), "Expected _get_heap_handle() not to return GetProcessHeap()\n");
|
||||
}
|
||||
|
||||
START_TEST(heap)
|
||||
{
|
||||
test_aligned();
|
||||
test_sbheap();
|
||||
test_malloc();
|
||||
test_calloc();
|
||||
test__get_heap_handle();
|
||||
}
|
||||
|
|
|
@ -1706,6 +1706,11 @@ static void test_gmtime64(void)
|
|||
tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
}
|
||||
|
||||
static void test__get_heap_handle(void)
|
||||
{
|
||||
ok((HANDLE)_get_heap_handle() == GetProcessHeap(), "Expected _get_heap_handle() to return GetProcessHeap()\n");
|
||||
}
|
||||
|
||||
START_TEST(misc)
|
||||
{
|
||||
int arg_c;
|
||||
|
@ -1752,4 +1757,5 @@ START_TEST(misc)
|
|||
test_rewind_i386_abi();
|
||||
#endif
|
||||
test_gmtime64();
|
||||
test__get_heap_handle();
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ _ACRTIMP int __cdecl _heapset(unsigned int);
|
|||
_ACRTIMP size_t __cdecl _heapused(size_t*,size_t*);
|
||||
_ACRTIMP int __cdecl _heapwalk(_HEAPINFO*);
|
||||
|
||||
_ACRTIMP intptr_t __cdecl _get_heap_handle(void);
|
||||
_ACRTIMP size_t __cdecl _get_sbh_threshold(void);
|
||||
_ACRTIMP int __cdecl _set_sbh_threshold(size_t size);
|
||||
|
||||
|
|
Loading…
Reference in a new issue