hooking HeapAlloc in multi-thread triggers exception if there is thread_local variable used in hooked function
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 6.4k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description

thread_local int g_cur_module_index = 0;
thread_local MemoryModule g_memory_module[MAX_MEMORY_HOOK_RECURSIVE_DEEP] = {};
When I compile the program with Debug mode, the exception is not thrown.
When I compile the program with Release mode, the exception is thown.
When I remove thread_local from g_cur_module_index and g_memory_module, the program runs OK in release mode。
Version 4.0.1 of Detours
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with Detours 4.0.1 using the shown thread_local globals and a function that hooks HeapAlloc. Compare Debug and Release builds, then verify that the Release build no longer throws the reported exception while thread_local remains in use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100