Skip to content

gccgo: no panic on nil pointer dereference on ^ operator #53019

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

Closed
ddaa2000 opened this issue May 21, 2022 · 2 comments
Closed

gccgo: no panic on nil pointer dereference on ^ operator #53019

ddaa2000 opened this issue May 21, 2022 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ddaa2000
Copy link

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

$ gccgo -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-12.1.0/bin/gccgo
COLLECT_LTO_WRAPPER=/usr/local/gcc-12.1.0/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-12.1.0/configure --prefix=/usr/local/gcc-12.1.0 --enable-languages=c,c++,go --with-arch-32=i586
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC) 

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://mirrors.aliyun.com/goproxy/"
GOROOT="/usr/local/go1.18.1"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go1.18.1/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="/usr/local/gcc-12.1.0/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build847055300=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://go.dev/play/p/jbdJGKWIsuL?v=gotip

What did you expect to see?

The program throws a panic.

What did you see instead?

The program finished running and print "no panic" in gccgo-6.1.0 and gccgo-12.1.0 (other versions are not tested).

@gopherbot gopherbot added this to the Gccgo milestone May 21, 2022
@ddaa2000
Copy link
Author

I'm not sure whether this is duplicated of #53012 so I reported this just in case.
The difference between them is that:

  1. This one can be triggered in gccgo-6.1.0 and gccgo: no panic on nil pointer dereference #53012 can only be triggered in gccgo-12.1.0.
  2. This one can only be triggered when the ^ operator is used, perhaps the compiler optmized the operator since its value should be a constant if no panic is thrown.
  3. This one can be triggerd even with the -O0 option.

However, it also can be the same bug about the optimization failed to consider the panic situation. Maybe the best way is to check whether the fix for #53012 can fix this one.

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 23, 2022
@ianlancetaylor
Copy link
Contributor

This is also a GCC middle-end bug, but not one that I am going to try to tackle. I've filed https://gcc.gnu.org/PR106163 against GCC. Since this will have to be fixed by GCC maintainers, closing this issue in favor of that one. Thanks for reporting it.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2022
@golang golang locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants