Skip to content

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

@jcowgill

Description

@jcowgill

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions