Repository: go
Issue: runtime: TestASAN fails with SEGV on unknown address on linux/riscv64
Labels: OS-Linux,NeedsInvestigation,arch-riscv,compiler/runtime

```
#!watchflakes
post <- goos == "linux" && goarch == "riscv64" && log ~ `AddressSanitizer:DEADLYSIGNAL`
```

Building 1.20rc2 on Debian.

https://buildd.debian.org/status/fetch.php?pkg=golang-1.20&arch=riscv64&ver=1.20%7Erc2-1&stamp=1673197738&raw=0
https://buildd.debian.org/status/fetch.php?pkg=golang-1.20&arch=riscv64&ver=1.20%7Erc2-1&stamp=1673210057&raw=0

Tried twice, both fail with:

```
##### ../misc/cgo/testsanitizers
--- FAIL: TestASANLinkerX (50.78s)
    asan_test.go:140: /tmp/.3038941009/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==2229782==ERROR: AddressSanitizer: SEGV on unknown address 0x00081a64f740 (pc 0x00000006b860 bp 0x003fd327bad0 sp 0x003fd327b9c0 T0)
        ==2229782==The signal is caused by a WRITE memory access.
            #0 0x6b860 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x63c9a in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
        
        AddressSanitizer can not provide additional info.
        SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
        ==2229782==ABORTING
--- FAIL: TestASAN (194.40s)
    --- FAIL: TestASAN/asan_unsafe_fail3 (8.81s)
        asan_test.go:95: `/tmp/TestASAN2813184920/asan_unsafe_fail3` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231530==ERROR: AddressSanitizer: SEGV on unknown address 0x00081bcbc93c (pc 0x000000125260 bp 0x003fde5e4ab0 sp 0x003fde5e49a0 T0)
            ==2231530==The signal is caused by a WRITE memory access.
                #0 0x125260 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231530==ABORTING
    --- FAIL: TestASAN/asan_global5 (9.76s)
        asan_test.go:97: /tmp/TestASAN3609951685/asan_global5 exited with exit status 1
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231586==ERROR: AddressSanitizer: SEGV on unknown address 0x00081cf5e33c (pc 0x000000125618 bp 0x003fe7af1ac0 sp 0x003fe7af19b0 T0)
            ==2231586==The signal is caused by a WRITE memory access.
                #0 0x125618 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231586==ABORTING
    --- FAIL: TestASAN/asan1_fail (11.94s)
        asan_test.go:95: `/tmp/TestASAN54641818/asan1_fail` exited without expected memory access error
            heap-use-after-free; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231676==ERROR: AddressSanitizer: SEGV on unknown address 0x00081f368f3c (pc 0x000000125a1a bp 0x003ff9b47ac0 sp 0x003ff9b479b0 T0)
            ==2231676==The signal is caused by a WRITE memory access.
                #0 0x125a1a in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b402 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231676==ABORTING
    --- FAIL: TestASAN/asan_unsafe_fail2 (7.88s)
        asan_test.go:95: `/tmp/TestASAN2421896259/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231779==ERROR: AddressSanitizer: SEGV on unknown address 0x00081955bd3c (pc 0x0000001252e0 bp 0x003fcaadeab0 sp 0x003fcaade9a0 T0)
            ==2231779==The signal is caused by a WRITE memory access.
                #0 0x1252e0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231779==ABORTING
    --- FAIL: TestASAN/asan5_fail (9.05s)
        asan_test.go:95: `/tmp/TestASAN2780092511/asan5_fail` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231781==ERROR: AddressSanitizer: SEGV on unknown address 0x00081afcc53c (pc 0x0000001274a8 bp 0x003fd7e62ac0 sp 0x003fd7e629b0 T0)
            ==2231781==The signal is caused by a WRITE memory access.
                #0 0x1274a8 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231781==ABORTING
    --- FAIL: TestASAN/asan_unsafe_fail1 (10.89s)
        asan_test.go:95: `/tmp/TestASAN121050683/asan_unsafe_fail1` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2231946==ERROR: AddressSanitizer: SEGV on unknown address 0x00081e9f6f3c (pc 0x0000001252e0 bp 0x003ff4fb7ab0 sp 0x003ff4fb79a0 T0)
            ==2231946==The signal is caused by a WRITE memory access.
                #0 0x1252e0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2231946==ABORTING
    --- FAIL: TestASAN/asan3_fail (10.66s)
        asan_test.go:95: `/tmp/TestASAN781659404/asan3_fail` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232076==ERROR: AddressSanitizer: SEGV on unknown address 0x00081cfe473c (pc 0x000000070a10 bp 0x003fe7f23ac0 sp 0x003fe7f239b0 T0)
            ==2232076==The signal is caused by a WRITE memory access.
                #0 0x70a10 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6420a in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232076==ABORTING
    --- FAIL: TestASAN/asan_useAfterReturn (12.69s)
        asan_test.go:97: /tmp/TestASAN2805664159/asan_useAfterReturn exited with exit status 1
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232146==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ecb293c (pc 0x0000001277a0 bp 0x003ff6594ab0 sp 0x003ff65949a0 T0)
            ==2232146==The signal is caused by a WRITE memory access.
                #0 0x1277a0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232146==ABORTING
    --- FAIL: TestASAN/asan4_fail (9.07s)
        asan_test.go:95: `/tmp/TestASAN4279481713/asan4_fail` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232245==ERROR: AddressSanitizer: SEGV on unknown address 0x000818ffc53c (pc 0x000000070a64 bp 0x003fc7fe2ac0 sp 0x003fc7fe29b0 T0)
            ==2232245==The signal is caused by a WRITE memory access.
                #0 0x70a64 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6426a in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232245==ABORTING
    --- FAIL: TestASAN/asan_global4_fail (8.92s)
        asan_test.go:95: `/tmp/TestASAN3022414010/asan_global4_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232484==ERROR: AddressSanitizer: SEGV on unknown address 0x00081d6ff33c (pc 0x000000127ad0 bp 0x003feb7f9ab0 sp 0x003feb7f99a0 T0)
            ==2232484==The signal is caused by a WRITE memory access.
                #0 0x127ad0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b2c2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232484==ABORTING
    --- FAIL: TestASAN/asan_global3_fail (12.80s)
        asan_test.go:95: `/tmp/TestASAN3708145155/asan_global3_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232582==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ba49b3c (pc 0x000000127fdc bp 0x003fdd24dab0 sp 0x003fdd24d9a0 T0)
            ==2232582==The signal is caused by a WRITE memory access.
                #0 0x127fdc in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b432 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232582==ABORTING
    --- FAIL: TestASAN/asan_global2_fail (10.94s)
        asan_test.go:95: `/tmp/TestASAN2939476675/asan_global2_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232708==ERROR: AddressSanitizer: SEGV on unknown address 0x000819db6f3c (pc 0x0000001266ac bp 0x003fcedb7ab0 sp 0x003fcedb79a0 T0)
            ==2232708==The signal is caused by a WRITE memory access.
                #0 0x1266ac in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6bc8a in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232708==ABORTING
    --- FAIL: TestASAN/arena_fail (47.49s)
        asan_test.go:95: `/tmp/TestASAN3425815187/arena_fail` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232833==ERROR: AddressSanitizer: SEGV on unknown address 0x00081cffe33c (pc 0x00000006dd90 bp 0x003fe7ff1ac0 sp 0x003fe7ff19b0 T0)
            ==2232833==The signal is caused by a WRITE memory access.
                #0 0x6dd90 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x669e2 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232833==ABORTING
    --- FAIL: TestASAN/asan2_fail (10.10s)
        asan_test.go:95: `/tmp/TestASAN2122599923/asan2_fail` exited without expected memory access error
            heap-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232842==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ca76d3c (pc 0x000000127d2c bp 0x003fe53b6ac0 sp 0x003fe53b69b0 T0)
            ==2232842==The signal is caused by a WRITE memory access.
                #0 0x127d2c in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b462 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232842==ABORTING
    --- FAIL: TestASAN/asan_global1_fail (8.87s)
        asan_test.go:95: `/tmp/TestASAN1995782410/asan_global1_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==2232843==ERROR: AddressSanitizer: SEGV on unknown address 0x00081c4ce53c (pc 0x000000125e30 bp 0x003fe2672ab0 sp 0x003fe26729a0 T0)
            ==2232843==The signal is caused by a WRITE memory access.
                #0 0x125e30 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b432 in runtime.rt0_go /usr/lib/go-1.20/src/runtime/asm_riscv64.s:34
            
            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
            ==2232843==ABORTING
FAIL
```

It's built with go 1.19.4.

Kernel is `Linux 6.0.0-3-riscv64 #1 SMP Debian 6.0.7-1 (2022-11-05) riscv64 (riscv64)`

I think it's HiFive Unmatched board.