-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syscall: ptrace calls must all come from one thread #7699
Comments
[email protected] suggested that I add: func init() { runtime.LockOSThread() } to the program. This does indeed seem to fix the problem! The 'SysProcAttr'ibutes includes (as used in the program above) an attribute to indicate that one wants to trace the spawned process. It seems from this example that the default setup, however, will never work without locking the thread. Perhaps forkAndExecInChild should lock the thread for the user, then? |
All calls to ptrace for a given child must be made from the same thread. It's a ptrace API bug that no Unix vendor has bothered to fix. There are many such problems with ptrace. I am not sure we can document them all, or even in enough detail to explain how to use it. Syscall in particular is mostly undocumented. Perhaps some day operating systems will have a good API for debugging programs. Status changed to Unfortunate. |
Unfortunate indeed, I just wasted many days of project progress on this bug. 😿 I was intercepting syscalls using ptrace's I think either:
I realize this is a stupid (non-Go) API fragility, but the current Go API inferface implementation is both guaranteed to break by default for non-trivial ptrace use cases and, while known to be so, is not documented to say so. Perhaps this was less of a major issue back at 1.3 when GOMAXPROCs defaulted to 1? @rsc @ianlancetaylor Does this need to be re-evaluated in light of the GOMAXPROCs change that took place with Go 1.5? |
This is unrelated to GOMAXPROCS. |
...that is, even with GOMAXPROCS 1, Go has always used different threads. |
OK, thanks for the clarification, I wasn't sure if that was the case. I still think something should be done, even if its a single sentence of documentation. That of course is just an opinion. |
Two year old issues are not the place for this, though. This bug is already fixed. In fact, we're about to deploy a bot to auto-freeze all old closed issues. Please open a new one for documentation. |
by tom.fogal:
The text was updated successfully, but these errors were encountered: