From b8856be903da81a645a29442235309b50c0b82c4 Mon Sep 17 00:00:00 2001 From: microsoftv <6063922+microsoftv@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:59:54 -0400 Subject: [PATCH] fallback to std malloc --- src/core/linker.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 57ef1542e..882047f88 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -336,9 +336,17 @@ void Linker::InitTlsForThread(bool is_primary) { ASSERT_MSG(ret == 0, "Unable to allocate TLS+TCB for the primary thread"); } else { if (heap_api) { - addr_out = heap_api->heap_malloc(total_tls_size); - } else { + LOG_ERROR(Core_Linker, "TLS user malloc called, using std::malloc"); + // TODO: ref rtld_tls_block_malloc, tls malloc replacement + //addr_out = heap_api->heap_malloc(total_tls_size); addr_out = std::malloc(total_tls_size); + if (!addr_out) { + auto pth_id = pthread_self(); + auto handle = pthread_gethandle(pth_id); + ASSERT_MSG(addr_out, + "Cannot allocate TLS block defined for handle=%x, index=%d size=%d", + handle, pth_id, total_tls_size); + } } }