kill maybe used to synchronize with ptrace where PTRACE_SYSCALL will run to the next syscall. By having a getpid call after the kill this may cause certain issues with unit tests running with ptrace and tsan. Record the result of the getpid comparison so that a second getpid call isn't necessary after the real kill call.
Do similar for pthread_kill.
Details
Details
- Reviewers
dvyukov
Diff Detail
Diff Detail
Event Timeline
Comment Actions
We are querying own PID, I don't understand how it can be wrong. We definitely did not kill itself if we are still running :)
Please add a test that exposes the problem. Will also help to understand what scenario we are fixing.
Comment Actions
Thanks Dmitry, the problem isn't that the getpid is wrong per se, the scenario is:
- ptraced program self stops with a SIGSTOP either by raise, kill, ..
- ptracing program attaches... and issues PTRACE_SYSCALL to resume the ptraced program until the next syscall,
- normally this would be some expected syscall, with tsan it will always be the getpid here.
As we'd like tests to pass with tsan, then we either teach the code to ignore getpid when running with tsan or avoid the interception using assembly - both of which are somewhat ugly workarounds.
While adding a test is attractive the harnessing of a parent/child process plus variants for OS and architecture, mean test code would dwarf what is a somewhat straightforward change.