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: mkerrors.sh broken on AIX #69365

Closed
jtroy opened this issue Sep 10, 2024 · 3 comments
Closed

x/sys/unix: mkerrors.sh broken on AIX #69365

jtroy opened this issue Sep 10, 2024 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jtroy
Copy link

jtroy commented Sep 10, 2024

Go version

go version go1.23.1 aix/ppc64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='ppc64'
GOBIN=''
GOCACHE='/home/jtroy/.cache/go-build'
GOENV='/home/jtroy/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='ppc64'
GOHOSTOS='aix'
GOINSECURE=''
GOMODCACHE='/home/jtroy/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='aix'
GOPATH='/home/jtroy/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/jtroy/go1.23.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/jtroy/go1.23.1/pkg/tool/aix_ppc64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/jtroy/.config/go/telemetry'
GCCGO='gccgo'
GOPPC64='power8'
AR='ar'
CC='gcc-12'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/jtroy/src/sys/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -maix64 -pthread -mcmodel=large -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4197857588=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I ran mkerrors.sh in the unix directory in order to regenerate zerrors_aix_ppc64.go according to the README.

What did you see happen?

The process crashed with a segfault:

bash-5.2$ pwd
/home/jtroy/src/sys/unix
bash-5.2$ CC=gcc-12 GOOS=aix GOARCH=ppc64 ./mkerrors.sh
[lots of generated Go output omitted]

// Signal table
var signalList = [...]struct {
        num  syscall.Signal
        name string
        desc string
} {
        { 1, "SIGHUP", "hangup" },
        { 2, "SIGINT", "interrupt" },
        { 3, "SIGQUIT", "quit" },
        { 4, "SIGILL", "illegal instruction" },
        { 5, "SIGTRAP", "trace/BPT trap" },
        { 6, "SIGLOST", "IOT/Abort trap" },
        { 7, "SIGEMT", "EMT trap" },
        { 8, "SIGFPE", "floating point exception" },
        { 9, "SIGKILL", "killed" },
        { 10, "SIGBUS", "bus error" },
        { 11, "SIGSEGV", "segmentation fault" },
        { 12, "SIGSYS", "bad system call" },
        { 13, "SIGPIPE", "broken pipe" },
        { 14, "SIGALRM", "alarm clock" },
        { 15, "SIGTERM", "terminated" },
        { 16, "SIGURG", "urgent I/O condition" },
        { 17, "SIGSTOP", "stopped (signal)" },
        { 18, "SIGTSTP", "stopped" },
        { 19, "SIGCONT", "continued" },
        { 20, "SIGCLD", "child exited" },
        { 21, "SIGTTIN", "stopped (tty input)" },
        { 22, "SIGTTOU", "stopped (tty output)" },
        { 23, "SIGPTY", "I/O possible/complete" },
        { 24, "SIGXCPU", "cputime limit exceeded" },
        { 25, "SIGXFSZ", "filesize limit exceeded" },
        { 27, "SIGMSG", "input device data" },
        { 28, "SIGWINCH", "window size changes" },
        { 29, "SIGPWR", "power-failure" },
        { 30, "SIGUSR1", "user defined signal 1" },
        { 31, "SIGUSR2", "user defined signal 2" },
        { 32, "SIGPROF", "profiling timer expired" },
        { 33, "SIGDANGER", "paging space low" },
        { 34, "SIGVTALRM", "virtual timer expired" },
        { 35, "SIGMIGRATE", "signal 35" },
        { 36, "SIGPRE", "signal 36" },
        { 37, "SIGVIRT", "signal 37" },
        { 38, "SIGALRM1", "signal 38" },
        { 39, "SIGWAITING", "signal 39" },
        { 48, "SIGSYSERROR", "signal 48" },
        { 49, "SIGCAPI", "signal 49" },
        { 50, "SIGRTMIN", "signal 50" },
        { 57, "SIGRTMAX", "signal 57" },
        { 58, "SIGRECONFIG", "signal 58" },
        { 59, "SIGCPUFAIL", "CPU Failure Predicted" },
        { 60, "SIGGRANT", "monitor mode granted" },
        { 61, "SIGRETRACT", "monitor mode retracted" },
        { 62, "SIGSOUND", "sound completed" },
        { 63, "SIGMAX", "secure attention" },
./mkerrors.sh: line 793: 24052120 Segmentation fault      (core dumped) $GORUN ./_errors

What did you expect to see?

I expected mkerrors.sh to produce complete output on aix/ppc64 without crashing.

Debugging further:

bash-5.2$ CC=gcc-12 GOOS=aix GOARCH=ppc64 ./mkerrors.sh -g
[stdout omitted]
./mkerrors.sh: line 793: 20316654 Segmentation fault      (core dumped) $GORUN ./_errors
bash-5.2$ gdb _errors core
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-ibm-aix7.1.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from _errors...
Core was generated by `_errors'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x10000b54 in strncpy ()
(gdb) up
#1  0x100008e4 in main () at _errors.c:245
245                     strncpy(buf, strsignal(e), sizeof(buf) - 1);
(gdb) p e
$1 = 255
(gdb) p signals[i]
$2 = {num = 255, name = 0x10001878 <_GLOBAL__FD__errors+1564> "SIGMAX64"}

The program attempts to call strsignal() against SIGMAX64, which is not a real signal and is not a valid thing to do. Digging further, it seems the intent is to filter SIGMAX64 out with grep, but using a GNU syntax which doesn't behave the same way with AIX's grep. It looks like it may have broken in x/sys #137. The OS is AIX 7.3.

I've submitted a proposed fix in golang/sys#217

@gopherbot gopherbot added this to the Unreleased milestone Sep 10, 2024
@timothy-king timothy-king changed the title x/sys: mkerrors.sh broken on AIX x/sys/unix: mkerrors.sh broken on AIX Sep 11, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 11, 2024
@timothy-king timothy-king modified the milestones: Unreleased, Backlog Sep 11, 2024
@timothy-king
Copy link
Contributor

CC @golang/runtime, @ianlancetaylor, @bradfitz, @tklauser per owners for x/sys/unix.

@timothy-king timothy-king added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 11, 2024
@mknyszek mknyszek moved this to In Progress in Go Compiler / Runtime Sep 18, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/615755 mentions this issue: unix: fix grep syntax to work on non-GNU greps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

Successfully merging a pull request may close this issue.

4 participants