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

os/signal: sending SIGTSTP doesn't return to shell when non-SIGTSTP handler exists (OpenBSD) #70548

Open
pafoster opened this issue Nov 24, 2024 · 8 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. OS-OpenBSD

Comments

@pafoster
Copy link

pafoster commented Nov 24, 2024

Go version

go version go1.20.1 openbsd/amd64

Output of go env in your module/workspace:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/peter/.cache/go-build"
GOENV="/home/peter/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="openbsd"
GOINSECURE=""
GOMODCACHE="/home/peter/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="openbsd"
GOPATH="/home/peter/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/openbsd_amd64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1289460440=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
        "os"
        "os/signal"
        "syscall"
        "time"
)

func main() {
        c := make(chan os.Signal, 1)
        signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
        go func() {
                <-c
                os.Exit(1)
        }()

        for {
                time.Sleep(time.Second)
        }
}

go build test.go
./test
Hit Ctrl-Z

What did you see happen?

<Doesn't return to shell as expected>

What did you expect to see?

^Z[1] + Suspended            ./test 
me@mymachine:~$ 
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 24, 2024
@seankhliao
Copy link
Member

is that a problem with your shell?
also, 1.20 is no longer a supported version.

@seankhliao seankhliao added OS-OpenBSD WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 24, 2024
@pafoster
Copy link
Author

Using the above code, I get the same issue with ksh, bash, and csh.

By comparison, the issue doesn't occur if I run the following and hit Ctrl-Z:

package main

import (
    "time"
)

func main() {
    for {
        time.Sleep(time.Second)
    }
}

@pafoster
Copy link
Author

I will try to reproduce also using a more recent version of Go.

@ianlancetaylor
Copy link
Member

CC @golang/openbsd

@pafoster
Copy link
Author

pafoster commented Dec 1, 2024

I can confirm that I observe the same issue with Go 1.23:

Go version

go version go1.23.1 openbsd/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/peter/.cache/go-build'
GOENV='/home/peter/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='openbsd'
GOINSECURE=''
GOMODCACHE='/home/peter/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='openbsd'
GOPATH='/home/peter/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/openbsd_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/peter/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3532196186=/tmp/go-build -gno-record-gcc-switches'

@pafoster pafoster closed this as completed Dec 1, 2024
@pafoster pafoster reopened this Dec 1, 2024
@github-project-automation github-project-automation bot moved this from Done to In Progress in Go Compiler / Runtime Dec 1, 2024
@seankhliao seankhliao removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 14, 2024
@4a6f656c
Copy link
Contributor

4a6f656c commented Jan 4, 2025

What version of OpenBSD are you running this on?

I suspect it is kernel bug that has been fixed in recent snapshots - I'm able to successfully suspend and resume the test program on a current snapshot, while it failed as described on a snapshot from a few months back.

@pafoster
Copy link
Author

pafoster commented Jan 5, 2025

I'm running the most recent release - OpenBSD 7.6. I don't run snapshots, but I'll re-run when the next release is made available.

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. OS-OpenBSD
Projects
Status: In Progress
Development

No branches or pull requests

7 participants
@ianlancetaylor @4a6f656c @gopherbot @pafoster @seankhliao @gabyhelp and others