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: struct PtraceRegs is wrong on mips* #20338

Closed
jcowgill opened this issue May 12, 2017 · 1 comment
Closed

x/sys/unix: struct PtraceRegs is wrong on mips* #20338

jcowgill opened this issue May 12, 2017 · 1 comment

Comments

@jcowgill
Copy link
Contributor

What version of Go are you using (go version)?

go version go1.8.1 linux/mips64le

What operating system and processor architecture are you using?

Debian Stretch mips64el

What did you do?

Run this:

package main

import (
        "fmt"
        "os/exec"
        "runtime"
        "syscall"

        "golang.org/x/sys/unix"
)

func main() {
        runtime.LockOSThread()

        cmd := exec.Command("/bin/true")
        cmd.SysProcAttr = &syscall.SysProcAttr{ Ptrace: true }
        err := cmd.Start()
        if err != nil {
                return
        }

        var status unix.WaitStatus
        _, err = unix.Wait4(cmd.Process.Pid, &status, 0, nil)
        if err != nil {
                return
        }

        var regs unix.PtraceRegs
        err = unix.PtraceGetRegs(cmd.Process.Pid, &regs)
        if err != nil {
                return
        }

        fmt.Printf("%#016x\n", regs.PC())
}

What did you expect to see?

The initial program counter of /bin/true.

What did you see instead?

Always 0x0000000000000000


Related: https://go-review.googlesource.com/c/43133/

The bug exists because the C structure unix.PtraceRegs is based on struct user but it should be using struct pt_regs on MIPS.

@gopherbot gopherbot added this to the Unreleased milestone May 12, 2017
@gopherbot
Copy link

CL https://golang.org/cl/43431 mentions this issue.

@golang golang locked and limited conversation to collaborators May 12, 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

2 participants