[sanitizer] Fix race condition in GetNamedMappingFd with decorate_pro… (#190981)
…c_maps=1
Multi-threaded programs crash randomly when
ASAN_OPTIONS=decorate_proc_maps=1 is enabled due to filename collision
in /dev/shm.
Root Cause:
All threads use the same filename format '/dev/shm/<PID> [name]',
causing race conditions where one thread deletes a file created by
another thread, resulting in ENOENT errors.
Solution:
Add thread ID (TID) to the filename to ensure uniqueness:
- Old format: /dev/shm/<PID> [name]
- New format: /dev/shm/<PID>.<TID> [name]
This ensures each thread has a unique filename, eliminating the race
condition.
Testing:
- Original version: 30% crash rate (6 crashes in 20 runs)
- Fixed version: 0% crash rate (0 crashes in 50 runs)
Fixes #190604