We seem to assume that OS-provided thread IDs are either uptr or int, neither of which is true on Darwin. This introduces a tid_t type, which holds a OS-provided thread ID (gettid on Linux, pthread_threadid_np on Darwin, pthread_self on FreeBSD).
Details
- Reviewers
kcc filcab dvyukov eugenis alekseyshl rnk fjricci - Commits
- rGceb30b071745: [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDs
rCRT300473: [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDs
rL300473: [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDs
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/sanitizer_common/sanitizer_stoptheworld.h | ||
---|---|---|
21 ↗ | (On Diff #94391) | Will it be problematic to move SuspendedThreadID from int to uptr on Linux? |
lib/sanitizer_common/sanitizer_stoptheworld.h | ||
---|---|---|
21 ↗ | (On Diff #94391) | I don't see any problems besides using a little bit more space in SuspendedThreadsList below. I guess we could #ifdef tid_t to int/pid_t on Linux, because that's what gettid returns. |
lib/sanitizer_common/sanitizer_stoptheworld.h | ||
---|---|---|
21 ↗ | (On Diff #94391) | I also wasn't sure if we ever used something like -1 for an error condition, but it doesn't appear so. I don't have any objection to uptr, since it seems that most of the code uses that anyway. |
lib/lsan/lsan_common.cc | ||
---|---|---|
191 ↗ | (On Diff #94391) | This line should remain os_id |
lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | ||
---|---|---|
84 ↗ | (On Diff #94391) | Hrm, this compiler check fails on my machine (CentOS 7 building for i386) |
As an aside we may want pthread_getthreadid_np() (the user-facing thread ID) on FreeBSD instead of pthread_self() (an opaque pointer), as a separate / later change.
Updating the patch and rebasing. Would you mind testing if this patch works on Linux? Thanks!