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

runtime: segment violation when large slice allocation on riscv64 #51835

Open
jagan-sivakumar opened this issue Mar 21, 2022 · 4 comments
Open

runtime: segment violation when large slice allocation on riscv64 #51835

jagan-sivakumar opened this issue Mar 21, 2022 · 4 comments
Labels
NeedsInvestigation

Comments

@jagan-sivakumar
Copy link

@jagan-sivakumar jagan-sivakumar commented Mar 21, 2022

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

$ go version
go version go1.17.8 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/jagan/.cache/go-build"
GOENV="/home/jagan/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jagan/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jagan/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build1188345552=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Trying to run a sample GO program cross compiled to RISCV platform.

Sample GO Program:

package main
import (  
    "fmt"
    "math/rand"
)
func main() {
    fmt.Println("Enter array size: ")
    var arraySize int
    fmt.Scanln(&arraySize)
    list := make([]float64, arraySize)
    for i := 0; i < arraySize; i++ {
        list[i] = rand.Float64()
    }
    for i := 0; i < arraySize; i++ {
        if( i % 100000 == 0){
                fmt.Print("Index[")
                fmt.Print(i)
                fmt.Print("] =")
                fmt.Println(list[i])
        }
    }
}

Compile Command :

GOOS=linux GOARCH=riscv64 go build -o bin/go-array go-array.go

GO-large-array-compile

What did you expect to see?

Display random value in array list in RISCV platform

What did you see instead?

Getting segmentation violation issue when performing read and write in large array list.

Text Log:

/go-test # env GOGC=50 GODEBUG=gctrace=1 GOTRACEBACK=crash ./go-array-riscv 
Enter array size: 
10000000
gc 1 @1458.220s 0%: 29+14830+12 ms clock, 29+0/3705/0+12 ms cpu, 76->76->76 MB, 76 MB goal, 0 MB stacks, 0 MB globals, 1 P
GC forced
gc 2 @1593.150s 0%: 27+5800+7.8 ms clock, 27+0/1449/0+7.8 ms cpu, 76->76->76 MB, 114 MB goal, 0 MB stacks, 0 MB globals, 1 P
GC forced
gc 3 @1719.021s 0%: 33+5560+7.3 ms clock, 33+0/1406/0+7.3 ms cpu, 76->76->76 MB, 114 MB goal, 0 MB stacks, 0 MB globals, 1 P
GC forced
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]

runtime stack:
runtime.throw({0xbe0e4, 0x2a})
	/usr/local/go/src/runtime/panic.go:992 +0x58 fp=0x3fc403ff60 sp=0x3fc403ff38 pc=0x41420
runtime: unexpected return pc for runtime.sigpanic called from 0x1
stack: frame={sp:0x3fc403ff60, fp:0x3fc403ff90} stack=[0x3fc403e000,0x3fc4040000)
0x0000003fc403fe60:  0x0000000000000000  0x0000000000041698 <runtime.fatalthrow.func1+0x0000000000000050> 
0x0000003fc403fe70:  0x0000000000041420 <runtime.throw+0x0000000000000058>  0x0000003fc403ff38 
0x0000003fc403fe80:  0x0000000000000000  0x0000003fc4002820 
0x0000003fc403fe90:  0x01000000000419d8  0x000000000000000b 
0x0000003fc403fea0:  0x000000000000001f  0x0000000000000000 
0x0000003fc403feb0:  0x0000000000000000  0x0000000000000001 
0x0000003fc403fec0:  0x00000000000bc31e  0x0000000000041630 <runtime.fatalthrow+0x0000000000000048> 
0x0000003fc403fed0:  0x0000003fc4002820  0x0000000000041420 <runtime.throw+0x0000000000000058> 
0x0000003fc403fee0:  0x0000003fc403ff38  0x0000000000042e40 <runtime.printunlock+0x0000000000000050> 
0x0000003fc403fef0:  0x0000003fc403ff38  0x0000000000041420 <runtime.throw+0x0000000000000058> 
0x0000003fc403ff00:  0x0000003fc4002820  0x0000000000041420 <runtime.throw+0x0000000000000058> 
0x0000003fc403ff10:  0x0000003fc403ff18  0x0000000000041648 <runtime.fatalthrow.func1+0x0000000000000000> 
0x0000003fc403ff20:  0x0000003fc4002820  0x0000000000041420 <runtime.throw+0x0000000000000058> 
0x0000003fc403ff30:  0x0000003fc403ff38  0x00000000000567e0 <runtime.sigpanic+0x0000000000000230> 
0x0000003fc403ff40:  0x0000003fc403ff48  0x0000000000041448 <runtime.throw.func1+0x0000000000000000> 
0x0000003fc403ff50:  0x00000000000be0e4  0x000000000000002a 
0x0000003fc403ff60: <0x0000000000000001  0x00000000000be0e4 
0x0000003fc403ff70:  0x000000000000002a  0x0000003fc942ec60 
0x0000003fc403ff80:  0x000000000015a518  0x0000000000028824 <runtime.gcResetMarkState+0x000000000000006c> 
0x0000003fc403ff90: >0x0000000000000001  0x0000000000025a5c <runtime.gcStart.func1+0x000000000000001c> 
0x0000003fc403ffa0:  0x00000000001801c8  0x0000003fc91f4400 
0x0000003fc403ffb0:  0x0000000600000001  0x0000000000000004 
0x0000003fc403ffc0:  0x0000000000000000  0x00000000001801c0 
0x0000003fc403ffd0:  0x000000000006a818 <runtime.systemstack+0x0000000000000050>  0x000000000006a78c <runtime.mstart+0x000000000000000c> 
0x0000003fc403ffe0:  0x00000000000004d2  0x000000000006a780 <runtime.mstart+0x0000000000000000> 
0x0000003fc403fff0:  0xffffffc03bfc2000  0x000000000006dd58 <runtime.clone+0x0000000000000078> 
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:802 +0x230 fp=0x3fc403ff90 sp=0x3fc403ff60 pc=0x567e0

goroutine 2 [running]:
runtime.systemstack_switch()
	/usr/local/go/src/runtime/asm_riscv64.s:96 +0x8 fp=0x3fc402af38 sp=0x3fc402af30 pc=0x6a7b0
runtime.gcStart({0x1, 0x29b5fbb7404, 0x0})
	/usr/local/go/src/runtime/mgc.go:663 +0x500 fp=0x3fc402afb0 sp=0x3fc402af38 pc=0x25f78
runtime.forcegchelper()
	/usr/local/go/src/runtime/proc.go:307 +0x64 fp=0x3fc402afd8 sp=0x3fc402afb0 pc=0x43e44
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc402afd8 sp=0x3fc402afd8 pc=0x6c5dc
created by runtime.init.5
	/usr/local/go/src/runtime/proc.go:289 +0x28

goroutine 1 [runnable]:
math/rand.Float64()
	/usr/local/go/src/math/rand/rand.go:341 +0xc fp=0x3fc4056ea8 sp=0x3fc4056ea8 pc=0x9df84
main.main()
	/go-test/go-array.go:14 +0x138 fp=0x3fc4056f80 sp=0x3fc4056ea8 pc=0x9e708
runtime.main()
	/usr/local/go/src/runtime/proc.go:250 +0x228 fp=0x3fc4056fd8 sp=0x3fc4056f80 pc=0x43bc8
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc4056fd8 sp=0x3fc4056fd8 pc=0x6c5dc

goroutine 3 [GC sweep wait]:
runtime.gopark(0xbfbf0, 0x159d80, 0xc, 0x14, 0x1)
	/usr/local/go/src/runtime/proc.go:361 +0xfc fp=0x3fc402b7a0 sp=0x3fc402b788 pc=0x4401c
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:367
runtime.bgsweep(0x3fc4048000)
	/usr/local/go/src/runtime/mgcsweep.go:297 +0x138 fp=0x3fc402b7c8 sp=0x3fc402b7a0 pc=0x30758
runtime.gcenable.func1()
	/usr/local/go/src/runtime/mgc.go:177 +0x2c fp=0x3fc402b7d8 sp=0x3fc402b7c8 pc=0x25954
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc402b7d8 sp=0x3fc402b7d8 pc=0x6c5dc
created by runtime.gcenable
	/usr/local/go/src/runtime/mgc.go:177 +0x90

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xbfbf0, 0x159d40, 0xd, 0x14, 0x1)
	/usr/local/go/src/runtime/proc.go:361 +0xfc fp=0x3fc402bef8 sp=0x3fc402bee0 pc=0x4401c
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:367
runtime.bgscavenge(0x3fc4048000)
	/usr/local/go/src/runtime/mgcscavenge.go:364 +0x32c fp=0x3fc402bfc8 sp=0x3fc402bef8 pc=0x2e39c
runtime.gcenable.func2()
	/usr/local/go/src/runtime/mgc.go:178 +0x2c fp=0x3fc402bfd8 sp=0x3fc402bfc8 pc=0x258f4
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc402bfd8 sp=0x3fc402bfd8 pc=0x6c5dc
created by runtime.gcenable
	/usr/local/go/src/runtime/mgc.go:178 +0xe8

goroutine 5 [finalizer wait, 6 minutes]:
runtime.gopark(0xbfbf0, 0x186788, 0x10, 0x14, 0x1)
	/usr/local/go/src/runtime/proc.go:361 +0xfc fp=0x3fc402a738 sp=0x3fc402a720 pc=0x4401c
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:367
runtime.runfinq()
	/usr/local/go/src/runtime/mfinal.go:177 +0xd0 fp=0x3fc402a7d8 sp=0x3fc402a738 pc=0x24960
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc402a7d8 sp=0x3fc402a7d8 pc=0x6c5dc
created by runtime.createfing
	/usr/local/go/src/runtime/mfinal.go:157 +0x60

goroutine 6 [GC worker (idle)]:
runtime.gopark(0xbfad8, 0x3fc4070000, 0x18, 0x14, 0x0)
	/usr/local/go/src/runtime/proc.go:361 +0xfc fp=0x3fc402c758 sp=0x3fc402c740 pc=0x4401c
runtime.gcBgMarkWorker()
	/usr/local/go/src/runtime/mgc.go:1207 +0x114 fp=0x3fc402c7d8 sp=0x3fc402c758 pc=0x27a54
runtime.goexit()
	/usr/local/go/src/runtime/asm_riscv64.s:497 +0x4 fp=0x3fc402c7d8 sp=0x3fc402c7d8 pc=0x6c5dc
created by runtime.gcBgMarkStartWorkers
	/usr/local/go/src/runtime/mgc.go:1131 +0x2c
Aborted

Screenshot:
GO-large-array-error

@mengzhuo mengzhuo changed the title GO program - RISCV Environment - Segmentation violation affected/package: src/runtime runtime: segment violation when large slice allocation on riscv64 Mar 21, 2022
@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented Mar 21, 2022

I can't reproduce your issue on both Hifive unmatched and qemu(amd64)
BTW, Please edit your issue with text based log instead of screenshots.

@mengzhuo mengzhuo added the WaitingForInfo label Mar 21, 2022
@jagan-sivakumar
Copy link
Author

@jagan-sivakumar jagan-sivakumar commented Mar 21, 2022

I can't reproduce your issue on both Hifive unmatched and qemu(amd64) BTW, Please edit your issue with text based log instead of screenshots.

Thanks for quick response, Update the text log

@mengzhuo mengzhuo added NeedsInvestigation and removed WaitingForInfo labels Mar 21, 2022
@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented Mar 22, 2022

@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented May 16, 2022

Update, I've tried on master(9956996) can't reproduce either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

2 participants