Skip to content

When GOARCH is set to mipsle, sync/atomic.Loadint64 will prompt "invalid memory address or nil pointer dereference" when sync.WaitGroup exists in the structure #41970

Closed
@ssoor

Description

@ssoor

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

$ go version
go version go1.15 linux/amd64

yum package(Repository: epel):

golang-src-1.15.2-1.el7.noarch
golang-bin-1.15.2-1.el7.x86_64
golang-1.15.2-1.el7.x86_64
golang-misc-1.15.2-1.el7.noarch

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="/home/core/.cache/go-build"
GOENV="/home/core/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/mnt/source_code/golang/pkg/mod"
GOOS="linux"
GOPATH="/mnt/source_code/golang/"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/core/.go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/core/.go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/mnt/source_code/golang/src/github.com/ssoor/test/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-build294050133=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Build(x86):

$GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build-o testRun
$scp testRun root@xxxxxx:~/gogs/testRun

Run(mips):

$ ./testRun
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11b30]

goroutine 1 [running]:
runtime/internal/atomic.lockAndCheck(...)
        /home/core/.go/src/runtime/internal/atomic/atomic_mipsx.go:40
runtime/internal/atomic.Load64(0x81404c, 0x814040, 0x15060)
        /home/core/.go/src/runtime/internal/atomic/atomic_mipsx.go:93 +0x20
main.main()
        /mnt/source_code/golang/src/github.com/ssoor/test/main.go:23 +0x54

Source:

package main

import (
	"fmt"
	"sync"
	"sync/atomic"
)

type TestStruct struct {
	wgClose        sync.WaitGroup // When it exists, it will report an error, comment out it is normal
	requestTimeout int64
}

func main() {
	testV := TestStruct{}
	fmt.Println(atomic.LoadInt64(&testV.requestTimeout))
}

What did you expect to see?

0

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions