Skip to content
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

x/sys/unix: ptrace API assumes GOARCH(target) == GOARCH(host) #9739

Closed
4ad opened this issue Jan 30, 2015 · 6 comments
Closed

x/sys/unix: ptrace API assumes GOARCH(target) == GOARCH(host) #9739

4ad opened this issue Jan 30, 2015 · 6 comments

Comments

@4ad
Copy link
Member

4ad commented Jan 30, 2015

syscall.PtraceGetRegs uses syscall.PtraceRegs. syscall.PtraceRegs depends on the host, e.g. if your binary is linux/386 syscall.PtraceRegs has 16 registers. But it's possible to run that linux/386 on an amd64 kernel, and attach to an amd64 process. In that case, syscall.PtraceRegs is not good anymore because the amd64 variant has 26 registers.

I have found this while trying to debug an arm64 Go process using an arm Go debugger.

@4ad
Copy link
Member Author

4ad commented Jan 30, 2015

Well, obviously there is nothing we can do about this particular API, because of Go 1 contract, but presumably we can add Ptrace(Get|Set)Regs(386|Amd64) on both 386 and amd64. Thoughts?

@4ad 4ad changed the title syscall: ptrace API assumes GOOS(target) == GOOS(host) syscall: ptrace API assumes GOARCH(target) == GOARCH(host) Jan 30, 2015
@tv42
Copy link

tv42 commented Jan 30, 2015

Even with Go1 api freeze, golang.org/x/sys/unix can be fixed.

@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

Is it really unfixable without an API change?

@rsc rsc removed the Unfortunate label Apr 10, 2015
@4ad
Copy link
Member Author

4ad commented Apr 10, 2015

Well we can add more precise APIs, leaving the current one (assuming ARCH(target) == ARHC(host)) as is, but that's just adding stuff rather than fixing existing stuff, so I don't consider that as "fixing" anything.

And as for adding stuff, we can add it in some other repository, it doesn't have to be inside syscall.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@bradfitz bradfitz changed the title syscall: ptrace API assumes GOARCH(target) == GOARCH(host) x/sys/unix: ptrace API assumes GOARCH(target) == GOARCH(host) Feb 2, 2017
@bradfitz
Copy link
Contributor

bradfitz commented Feb 2, 2017

Repurposed this to be about x/sys/unix.

@gopherbot
Copy link

Change https://golang.org/cl/73555 mentions this issue: unix: add ptrace definitions for compatible GOARCH pairs

@golang golang locked and limited conversation to collaborators Oct 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants