mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Disable Heap Malloc on Linux
Disables heap malloc calls on Linux, as there are games where the heap malloc causes a crash. Note that the assert had to be modified, as pthread_gethandle is a winpthreads specific method. Also fixes a minor oversight that caused games not to perform TLS mallocs on Windows when there was no heap api.
This commit is contained in:
parent
edde0a3e7e
commit
0661c59eb1
@ -356,22 +356,21 @@ void Linker::InitTlsForThread(bool is_primary) {
|
|||||||
ASSERT_MSG(ret == 0, "Unable to allocate TLS+TCB for the primary thread");
|
ASSERT_MSG(ret == 0, "Unable to allocate TLS+TCB for the primary thread");
|
||||||
} else {
|
} else {
|
||||||
if (heap_api) {
|
if (heap_api) {
|
||||||
#ifndef WIN32
|
#ifdef __APPLE__
|
||||||
addr_out = heap_api->heap_malloc(total_tls_size);
|
addr_out = heap_api->heap_malloc(total_tls_size);
|
||||||
} else {
|
|
||||||
addr_out = std::malloc(total_tls_size);
|
|
||||||
#else
|
#else
|
||||||
// TODO: Windows tls malloc replacement, refer to rtld_tls_block_malloc
|
// TODO: Windows tls malloc replacement, refer to rtld_tls_block_malloc
|
||||||
LOG_ERROR(Core_Linker, "TLS user malloc called, using std::malloc");
|
LOG_ERROR(Core_Linker, "TLS user malloc called, using std::malloc");
|
||||||
addr_out = std::malloc(total_tls_size);
|
addr_out = std::malloc(total_tls_size);
|
||||||
if (!addr_out) {
|
if (!addr_out) {
|
||||||
|
// TODO: Properly log thread handle on assert.
|
||||||
auto pth_id = pthread_self();
|
auto pth_id = pthread_self();
|
||||||
auto handle = pthread_gethandle(pth_id);
|
ASSERT_MSG(addr_out, "Cannot allocate TLS block of size = {:#x} for thread {}",
|
||||||
ASSERT_MSG(addr_out,
|
total_tls_size, pth_id);
|
||||||
"Cannot allocate TLS block defined for handle=%x, index=%d size=%d",
|
|
||||||
handle, pth_id, total_tls_size);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
addr_out = std::malloc(total_tls_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user