Skip to content

syscall: wrong TCGETS value on ppc64le #22000

@zhsj

Description

@zhsj

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

go version go1.9 linux/ppc64le

Does this issue reproduce with the latest release?

yes, with go1.9

What operating system and processor architecture are you using (go env)?

GOARCH="ppc64le"
GOBIN=""
GOEXE=""
GOHOSTARCH="ppc64le"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/debian/go"
GORACE=""
GOROOT="/usr/lib/go-1.9"
GOTOOLDIR="/usr/lib/go-1.9/pkg/tool/linux_ppc64le"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build617591770=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

I meet strange output when I use github.com/mattn/go-isatty, the following snippet explains.


/*
#include <unistd.h>
*/
import "C"
import "unsafe"
import "syscall"
import "golang.org/x/sys/unix"

func main() {
        C.isatty(C.int(0))
        var termios syscall.Termios
        syscall.Syscall6(syscall.SYS_IOCTL, 0, syscall.TCGETS, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
        unix.Syscall6(unix.SYS_IOCTL, 0, unix.TCGETS, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
        syscall.Syscall6(syscall.SYS_IOCTL, 0, 0x402c7413, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
}

run strace to see the real syscall.

strace ./isatty 2>&1 |grep -i ioc
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, _IOC(_IOC_READ, 0x74, 0x13, 0x3c), 0xc42004fef8) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0

The syscall.TCGETS is wrong and should be 0x402c7413(the one in sys/unix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions