What version of Go are you using (go version)?
$ go version
go version go1.15.7 linux/amd64
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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ycd/.cache/go-build"
GOENV="/home/ycd/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ycd/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ycd/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ycd/Desktop/gopher/compilers/go.mod"
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-build268469538=/tmp/go-build -gno-record-gcc-switches"
What did you do?
- Created a new directory to create a reproducible minimal example, then i ran
go mod init my_mod.
- Created
main.go (see the code below.).
package main
import "fmt"
func main() {
a := 1+1
fmt.Printf("Sum: %v\n", a)
}
- Run the command
go run main.go compiled and runned fine.
- Run the command
go build main.go compiled fine.
- Then tested my
GOSSAFUNC=main go build main.go. Then i got the error below:
ERROR
$ GOSSAFUNC=main go build main.go
Out:
# runtime
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x673c27]
goroutine 132 [running]:
cmd/compile/internal/ssa.(*Func).Fatalf(...)
/usr/lib/go/src/cmd/compile/internal/ssa/func.go:618
cmd/compile/internal/ssa.NewHTMLWriter(0xc47802, 0x8, 0xc002eb0420, 0x0, 0x0, 0x1)
/usr/lib/go/src/cmd/compile/internal/ssa/html.go:33 +0xe7
cmd/compile/internal/gc.buildssa(0xc001967340, 0x2, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/ssa.go:342 +0x1165
cmd/compile/internal/gc.compileSSA(0xc001967340, 0x2)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:317 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc003fc4600, 0xc000bd6ed0, 0x2)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:382 +0x4d
created by cmd/compile/internal/gc.compileFunctions
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:380 +0x129
- Then i used
-a flag to force rebuild the packages.
- Got the same error.
ERROR
$ GOSSAFUNC=main go build -a main.go
Out:
# runtime
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x673c27]
goroutine 10 [running]:
cmd/compile/internal/ssa.(*Func).Fatalf(...)
/usr/lib/go/src/cmd/compile/internal/ssa/func.go:618
cmd/compile/internal/ssa.NewHTMLWriter(0xc47802, 0x8, 0xc002d362c0, 0x0, 0x0, 0x1)
/usr/lib/go/src/cmd/compile/internal/ssa/html.go:33 +0xe7
cmd/compile/internal/gc.buildssa(0xc00197da20, 0x3, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/ssa.go:342 +0x1165
cmd/compile/internal/gc.compileSSA(0xc00197da20, 0x3)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:317 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc003fdfaa0, 0xc0006aba10, 0x3)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:382 +0x4d
created by cmd/compile/internal/gc.compileFunctions
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:380 +0x129
Also output of GOSSAFUNC=main go build -x main.go maybe it helps.
Output
WORK=/tmp/go-build350137816
mkdir -p $WORK/b007/
cat >$WORK/b007/go_asm.h << 'EOF' # internal
EOF
cd /usr/lib/go/src/runtime
/usr/lib/go/pkg/tool/linux_amd64/asm -p runtime -trimpath "$WORK/b007=>" -I $WORK/b007/ -I /usr/lib/go/pkg/include -D GOOS_linux -D GOARCH_amd64 -gensymabis -o $WORK/b007/symabis ./asm.s ./asm_amd64.s ./duff_amd64.s ./memclr_amd64.s ./memmove_amd64.s ./preempt_amd64.s ./rt0_linux_amd64.s ./sys_linux_amd64.s
cat >$WORK/b007/importcfg << 'EOF' # internal
# import config
packagefile internal/bytealg=/home/ycd/.cache/go-build/ea/ea6029314d7c91dca51e1d5c3bbe5bd546f318cf194933c2836176f4f3aaf843-d
packagefile internal/cpu=/home/ycd/.cache/go-build/ed/edc8dddf2c412cfb53539974a0df1f0271acb9dab8ca107655ba4892063f4a65-d
packagefile runtime/internal/atomic=/home/ycd/.cache/go-build/d2/d2aa5e552aaee84240aa3ff18c9b82bacce1d1753e7fa08352ba5328be44cdfc-d
packagefile runtime/internal/math=/home/ycd/.cache/go-build/9b/9b0ddab4d0f4873a0a1f4f72fbfd8c624aba64f1dd9f5bd4f65f10a54afb7a21-d
packagefile runtime/internal/sys=/home/ycd/.cache/go-build/f3/f3a88869b5486853960400896d771d5c024725a3b8c835283088c3700ac07005-d
EOF
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/b007/_pkg_.a -trimpath "$WORK/b007=>" -p runtime -std -+ -buildid bMReDofeTU05e5N6jhKE/bMReDofeTU05e5N6jhKE -goversion go1.15.7 -symabis $WORK/b007/symabis -D "" -importcfg $WORK/b007/importcfg -pack -asmhdr $WORK/b007/go_asm.h -c=4 ./alg.go ./atomic_pointer.go ./cgo.go ./cgo_mmap.go ./cgo_sigaction.go ./cgocall.go ./cgocallback.go ./cgocheck.go ./chan.go ./checkptr.go ./compiler.go ./complex.go ./cpuflags.go ./cpuflags_amd64.go ./cpuprof.go ./cputicks.go ./debug.go ./debugcall.go ./debuglog.go ./debuglog_off.go ./defs_linux_amd64.go ./env_posix.go ./error.go ./extern.go ./fastlog2.go ./fastlog2table.go ./float.go ./hash64.go ./heapdump.go ./iface.go ./lfstack.go ./lfstack_64bit.go ./lock_futex.go ./lockrank.go ./lockrank_off.go ./malloc.go ./map.go ./map_fast32.go ./map_fast64.go ./map_faststr.go ./mbarrier.go ./mbitmap.go ./mcache.go ./mcentral.go ./mem_linux.go ./mfinal.go ./mfixalloc.go ./mgc.go ./mgcmark.go ./mgcscavenge.go ./mgcstack.go ./mgcsweep.go ./mgcsweepbuf.go ./mgcwork.go ./mheap.go ./mpagealloc.go ./mpagealloc_64bit.go ./mpagecache.go ./mpallocbits.go ./mprof.go ./mranges.go ./msan0.go ./msize.go ./mspanset.go ./mstats.go ./mwbbuf.go ./nbpipe_pipe2.go ./netpoll.go ./netpoll_epoll.go ./os_linux.go ./os_linux_generic.go ./os_linux_noauxv.go ./os_linux_x86.go ./os_nonopenbsd.go ./panic.go ./plugin.go ./preempt.go ./preempt_nonwindows.go ./print.go ./proc.go ./profbuf.go ./proflabel.go ./race0.go ./rdebug.go ./relax_stub.go ./runtime.go ./runtime1.go ./runtime2.go ./rwmutex.go ./select.go ./sema.go ./signal_amd64.go ./signal_linux_amd64.go ./signal_unix.go ./sigqueue.go ./sigqueue_note.go ./sigtab_linux_generic.go ./sizeclasses.go ./slice.go ./softfloat64.go ./stack.go ./string.go ./stubs.go ./stubs2.go ./stubs3.go ./stubs_amd64.go ./stubs_linux.go ./symtab.go ./sys_nonppc64x.go ./sys_x86.go ./time.go ./time_nofake.go ./timestub.go ./timestub2.go ./trace.go ./traceback.go ./type.go ./typekind.go ./utf8.go ./vdso_elf64.go ./vdso_linux.go ./vdso_linux_amd64.go ./write_err.go
# runtime
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x673c27]
goroutine 5 [running]:
cmd/compile/internal/ssa.(*Func).Fatalf(...)
/usr/lib/go/src/cmd/compile/internal/ssa/func.go:618
cmd/compile/internal/ssa.NewHTMLWriter(0xc47802, 0x8, 0xc0057186e0, 0x0, 0x0, 0x1)
/usr/lib/go/src/cmd/compile/internal/ssa/html.go:33 +0xe7
cmd/compile/internal/gc.buildssa(0xc001940b00, 0x0, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/ssa.go:342 +0x1165
cmd/compile/internal/gc.compileSSA(0xc001940b00, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:317 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc003d63800, 0xc0007c8c00, 0x0)
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:382 +0x4d
created by cmd/compile/internal/gc.compileFunctions
/usr/lib/go/src/cmd/compile/internal/gc/pgen.go:380 +0x129
I thought maybe this was a permission issue. But other tools were working fine.
However, i give the write access to the directory just to be sure.
Output of ls -l -a
ls -l -a
total 16
drwxrwxr-x 2 ycd users 4096 Jan 22 19:06 .
drwxr-xr-x 7 ycd users 4096 Jan 22 17:16 ..
-rw-r--r-- 1 ycd users 21 Jan 22 17:48 go.mod
-rw-r--r-- 1 ycd users 125 Jan 22 19:06 main.go
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
go mod init my_mod.main.go(see the code below.).go run main.gocompiled and runned fine.go build main.gocompiled fine.GOSSAFUNC=main go build main.go. Then i got the error below:ERROR
Out:
-aflag to force rebuild the packages.ERROR
Out:
Also output of
GOSSAFUNC=main go build -x main.gomaybe it helps.Output
I thought maybe this was a permission issue. But other tools were working fine.
However, i give the write access to the directory just to be sure.
sudo chmod 775 .Output of
ls -l -a