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: TestASAN fails with SEGV on unknown address on linux/riscv64 #57691

Open
zhsj opened this issue Jan 9, 2023 · 15 comments
Open

runtime: TestASAN fails with SEGV on unknown address on linux/riscv64 #57691

zhsj opened this issue Jan 9, 2023 · 15 comments
Assignees
Labels
arch-riscv Issues solely affecting the riscv64 architecture. compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Linux
Milestone

Comments

@zhsj
Copy link
Contributor

zhsj commented Jan 9, 2023

#!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.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 9, 2023
@mengzhuo mengzhuo added arch-riscv Issues solely affecting the riscv64 architecture. OS-Linux and removed arch-riscv Issues solely affecting the riscv64 architecture. labels Jan 9, 2023
@mengzhuo
Copy link
Contributor

mengzhuo commented Jan 9, 2023

cc @golang/riscv64
It looks real problem to me.
p.s. The linux/riscv builders are using Ubuntu 21.04 without llvm, all the asan related tests are skipped.

@cagedmantis cagedmantis added this to the Go1.20 milestone Jan 9, 2023
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 9, 2023
@bcmills
Copy link
Contributor

bcmills commented Jan 9, 2023

Looks like this test was enabled for riscv64 in CL 375256 (Go 1.19).

@bcmills bcmills modified the milestones: Go1.20, Go1.21 Jan 9, 2023
@zhsj
Copy link
Contributor Author

zhsj commented Jan 9, 2023

Looks like this test was enabled for riscv64 in CL 375256 (Go 1.19).

Then there's something broken. We can build Go 1.19 before. https://buildd.debian.org/status/logs.php?pkg=golang-1.19&arch=riscv64

@cherrymui
Copy link
Member

What version of the C compiler are you using? Thanks.

@zhsj
Copy link
Contributor Author

zhsj commented Jan 12, 2023

What version of the C compiler are you using? Thanks.

gcc-12 on Debian unstable. https://tracker.debian.org/pkg/gcc-12

@yuzibo
Copy link

yuzibo commented Jan 14, 2023

Hi,
If I am doing correctly, I git bisect got:

vimer@dev-rv-unmatched:~/build/go/go$ git bisect good
dfbecc06e73b79aaeee4220b3e760cbd76050ae5 is the first bad commit
commit dfbecc06e73b79aaeee4220b3e760cbd76050ae5
Author: Archana R <aravind5@in.ibm.com>
Date:   Wed Aug 10 09:57:51 2022 -0500

    misc/cgo/testsanitizers: fix code to detect gcc version correctly

    The current implementation of compilerVersion incorrectly gives an
    error message that the compiler version is too old even though the
    system has a recent compiler. This happens for specifically for the
    gcc compiler and causes ASAN tests to be skipped.
    Replacing -v with gcc dump version options seems to fix it. Running
    ./testsanitizers.test -test.v now shows the ASAN tests being run.
    --- PASS: TestASAN (16.81s)
        --- PASS: TestASAN/asan_useAfterReturn (0.60s)
        --- PASS: TestASAN/asan_global5 (0.61s)
        --- PASS: TestASAN/asan_unsafe_fail1 (0.73s)
        --- PASS: TestASAN/asan_unsafe_fail3 (0.73s)
        --- PASS: TestASAN/asan_unsafe_fail2 (0.74s)
        --- PASS: TestASAN/asan_global4_fail (0.74s)
        --- PASS: TestASAN/asan5_fail (0.74s)
        --- PASS: TestASAN/asan3_fail (0.88s)
        --- PASS: TestASAN/asan4_fail (0.89s)
        --- PASS: TestASAN/asan2_fail (0.99s)
        --- PASS: TestASAN/asan_global3_fail (1.00s)
        --- PASS: TestASAN/asan_global1_fail (1.01s)
        --- PASS: TestASAN/asan1_fail (1.01s)
        --- PASS: TestASAN/asan_global2_fail (1.02s)
    PASS

    Fixes #54370

    Change-Id: Iac13a1cf37de54432a6e49555f61e9ec1d781ab8
    Reviewed-on: https://go-review.googlesource.com/c/go/+/422574
    TryBot-Result: Gopher Robot <gobot@golang.org>
    Reviewed-by: Damien Neil <dneil@google.com>
    Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
    Reviewed-by: Than McIntosh <thanm@google.com>

 misc/cgo/testsanitizers/cc_test.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

My real riscv64 hardware is Unmatched also:

vimer@dev-rv-unmatched:~/build/go/go/src$ uname -a
Linux dev-rv-unmatched 6.1.0-1-riscv64 #1 SMP Debian 6.1.4-1 (2023-01-07) riscv64 GNU/Linux

@wdvxdr1123
Copy link
Contributor

@yuzibo I don't think it is the bad commit, it just enabled the tests. I can reproduce with go1.19.5 on my riscv64 hardware.

$ uname -a
Linux dev-visionfive2 5.15.0-cwt6-server #1 SMP Wed Feb 1 23:30:07 +07 2023 riscv64 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-unknown-linux-gnu/12.2.1/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,fortran,go,lto,objc,obj-c++,d --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.1 20230111 (GCC) 
$ go version
go version go1.19.5 linux/riscv64
$ go build -asan asan1_fail.go
$ ./asan1_fail
AddressSanitizer:DEADLYSIGNAL
=================================================================
==627==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ff69b14 (pc 0x0000001283aa bp 0x003fffb4d8a0 sp 0x003fffb4d870 T0)
==627==The signal is caused by a WRITE memory access.
    #0 0x1283aa in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /_/runtime/cgo/gcc_linux_riscv64.c:56 in x_cgo_init
==627==ABORTING

@mengzhuo
Copy link
Contributor

mengzhuo commented Feb 13, 2023

I can confirm gcc-12 is the culprit, gcc 11 passed all the tests.

Why asan accessing an unknown memory?

Here is the gcc12 build binary
asan2_fail.zip


=================================================================
==29473==ERROR: AddressSanitizer: SEGV on unknown address 0x00081aac1d1c (pc 0x00000012be3c bp
 0x003fd560e9b0 sp 0x003fd560e8a0 T0)
==29473==The signal is caused by a WRITE memory access.
    #0 0x12be3c in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
    #1 0x6b512 in runtime.rt0_go /root/godev/src/runtime/asm_riscv64.s:34


process 29473
Mapped address spaces:

          Start Addr           End Addr       Size     Offset objfile
             0x10000           0x1f5000   0x1e5000        0x0 /root/asan2_fail
            0x1f5000           0x1f6000     0x1000   0x1e4000 /root/asan2_fail
            0x1f6000           0x21d000    0x27000   0x1e5000 /root/asan2_fail
            0x21d000           0x25c000    0x3f000        0x0 [heap]
         0xd5554f000        0xeffffa000 0x1aaaab000        0x0
         0xeffffa000        0xfffffa000 0x100000000        0x0
         0xfffffa000       0x1555550000 0x555556000        0x0
        0x1ff5c00000       0x1ff5d00000   0x100000        0x0
        0x1ff5e00000       0x1ff5f00000   0x100000        0x0
        0x1ff6000000       0x1ff6100000   0x100000        0x0
        0x1ff61cf000       0x1ff62ef000   0x120000        0x0
        0x1ff62ef000       0x23f6af0000 0x400801000        0x0
        0x23f6af0000       0x23f6b00000    0x10000        0x0
        0x23f6b00000       0x24d6af0000 0xdfff0000        0x0
        0x24d6af0000       0x24d6b00000    0x10000        0x0
        0x24d6b00000       0x25f6af0000 0x11fff0000        0x0
        0x25f6af0000       0x25f6b00000    0x10000        0x0
        0x25f6b00000       0x26d6af0000 0xdfff0000        0x0
        0x26d6af0000       0x26d6b00000    0x10000        0x0
        0x26d6b00000       0x37f6af0000 0x111fff0000        0x0

@mengzhuo
Copy link
Contributor

@zhsj This might be a bug from libasan8.

asan 12.2.0 using SHADOW_OFFSET by 0xd55550000

static const u64 kRiscv64_ShadowOffset64 = 0xd55550000;
...
#elif SANITIZER_RISCV64
#define SHADOW_OFFSET kRiscv64_ShadowOffset64
...
#define MEM_TO_SHADOW(mem) (((mem) >> SHADOW_SCALE) + (SHADOW_OFFSET))

this should be (mem >> 3) + 0xd55550000

However I found that libasan8's SHADOW_OFFSET is 0x20000

0x129996 <x_cgo_init+116>       srli    s1,s2,0x3
0x12999a <x_cgo_init+120>       lui     a5,0x20000
0x12999e <x_cgo_init+124>       add     a5,a5,s1 

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- goos == "linux" && goarch == "riscv64" && log ~ `AddressSanitizer:DEADLYSIGNAL`
2023-02-10 19:39 linux-riscv64-unmatched go@88ad4476 misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (30.97s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.2896967049/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==529264==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ee0fe30 (pc 0x00000006c278 bp 0x003ff707f260 sp 0x003ff707f150 T0)
        ==529264==The signal is caused by a WRITE memory access.
            #0 0x6c278 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x6468a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==529264==ABORTING
2023-02-10 19:39 linux-riscv64-unmatched go@88ad4476 misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (108.93s)
    --- FAIL: TestASAN/asan_unsafe_fail2 (6.86s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN1982455376/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==530998==ERROR: AddressSanitizer: SEGV on unknown address 0x00081b77162c (pc 0x000000129418 bp 0x003fdbb8b240 sp 0x003fdbb8b130 T0)
            ==530998==The signal is caused by a WRITE memory access.
                #0 0x129418 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
    --- FAIL: TestASAN/asan5_fail (7.14s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN1735283211/asan5_fail` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==531020==ERROR: AddressSanitizer: SEGV on unknown address 0x00081e1cac30 (pc 0x00000012b618 bp 0x003ff0e56250 sp 0x003ff0e56140 T0)
            ==531020==The signal is caused by a WRITE memory access.
                #0 0x12b618 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==532393==ERROR: AddressSanitizer: SEGV on unknown address 0x00081bfe902c (pc 0x00000012b910 bp 0x003fdff48240 sp 0x003fdff48130 T0)
            ==532393==The signal is caused by a WRITE memory access.
                #0 0x12b910 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==532393==ABORTING
go tool dist: Failed: exit status 1
2023-02-10 21:19 linux-riscv64-unmatched go@117d5588 misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (31.03s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.4056423146/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==403595==ERROR: AddressSanitizer: SEGV on unknown address 0x00081e4e3a34 (pc 0x00000006c278 bp 0x003ff271d270 sp 0x003ff271d160 T0)
        ==403595==The signal is caused by a WRITE memory access.
            #0 0x6c278 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x6468a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==403595==ABORTING
2023-02-10 21:19 linux-riscv64-unmatched go@117d5588 misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (108.26s)
    --- FAIL: TestASAN/asan_global4_fail (6.28s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2527750257/asan_global4_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==405269==ERROR: AddressSanitizer: SEGV on unknown address 0x0008182e1e30 (pc 0x00000012bc40 bp 0x003fc170f250 sp 0x003fc170f140 T0)
            ==405269==The signal is caused by a WRITE memory access.
                #0 0x12bc40 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
    --- FAIL: TestASAN/asan_unsafe_fail3 (6.76s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2148382510/asan_unsafe_fail3` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==405319==ERROR: AddressSanitizer: SEGV on unknown address 0x00081bdeca30 (pc 0x0000001293a0 bp 0x003fdef65250 sp 0x003fdef65140 T0)
            ==405319==The signal is caused by a WRITE memory access.
                #0 0x1293a0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==406727==ERROR: AddressSanitizer: SEGV on unknown address 0x00081cdb2e30 (pc 0x00000006e7a8 bp 0x003fe6d97250 sp 0x003fe6d97140 T0)
            ==406727==The signal is caused by a WRITE memory access.
                #0 0x6e7a8 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x673d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==406727==ABORTING
go tool dist: Failed: exit status 1
2023-02-10 22:09 linux-riscv64-unmatched go@5c5f8dc9 misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (29.78s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.639834467/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==240946==ERROR: AddressSanitizer: SEGV on unknown address 0x000818b67234 (pc 0x00000006c278 bp 0x003fc5b39270 sp 0x003fc5b39160 T0)
        ==240946==The signal is caused by a WRITE memory access.
            #0 0x6c278 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x6468a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==240946==ABORTING
2023-02-10 22:09 linux-riscv64-unmatched go@5c5f8dc9 misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (106.98s)
    --- FAIL: TestASAN/asan_global5 (6.04s)
        asan_test.go:97: /tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN3622742880/asan_global5 exited with exit status 1
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==242663==ERROR: AddressSanitizer: SEGV on unknown address 0x00081de24830 (pc 0x000000129758 bp 0x003fef124250 sp 0x003fef124140 T0)
            ==242663==The signal is caused by a WRITE memory access.
                #0 0x129758 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
    --- FAIL: TestASAN/asan_unsafe_fail2 (6.35s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN3941682611/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==242699==ERROR: AddressSanitizer: SEGV on unknown address 0x00081d1cae2c (pc 0x000000129418 bp 0x003fe8e57240 sp 0x003fe8e57130 T0)
            ==242699==The signal is caused by a WRITE memory access.
                #0 0x129418 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b3d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==244070==ERROR: AddressSanitizer: SEGV on unknown address 0x0008198b0230 (pc 0x000000129f10 bp 0x003fcc581250 sp 0x003fcc581140 T0)
            ==244070==The signal is caused by a WRITE memory access.
                #0 0x129f10 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b4e2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==244070==ABORTING
go tool dist: Failed: exit status 1
2023-02-13 19:16 linux-riscv64-unmatched go@505325cf misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (30.37s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.3808423306/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==115629==ERROR: AddressSanitizer: SEGV on unknown address 0x00081d1b3c34 (pc 0x00000006c278 bp 0x003fe8d9e270 sp 0x003fe8d9e160 T0)
        ==115629==The signal is caused by a WRITE memory access.
            #0 0x6c278 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x6468a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==115629==ABORTING
2023-02-13 19:16 linux-riscv64-unmatched go@505325cf misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (105.99s)
    --- FAIL: TestASAN/asan_unsafe_fail2 (5.94s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2151778044/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==117376==ERROR: AddressSanitizer: SEGV on unknown address 0x000819f29630 (pc 0x000000129498 bp 0x003fcf94b250 sp 0x003fcf94b140 T0)
            ==117376==The signal is caused by a WRITE memory access.
                #0 0x129498 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b452 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
    --- FAIL: TestASAN/asan1_fail (8.39s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN1730192641/asan1_fail` exited without expected memory access error
            heap-use-after-free; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==117461==ERROR: AddressSanitizer: SEGV on unknown address 0x00081faa4e30 (pc 0x000000129b5a bp 0x003ffd527250 sp 0x003ffd527140 T0)
            ==117461==The signal is caused by a WRITE memory access.
                #0 0x129b5a in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b512 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==118715==ERROR: AddressSanitizer: SEGV on unknown address 0x000819c79a30 (pc 0x000000129420 bp 0x003fce3cd250 sp 0x003fce3cd140 T0)
            ==118715==The signal is caused by a WRITE memory access.
                #0 0x129420 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6b452 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==118715==ABORTING
go tool dist: Failed: exit status 1
2023-03-07 21:29 linux-riscv64-unmatched go@b675a75c misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (33.81s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.3304439204/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==757633==ERROR: AddressSanitizer: SEGV on unknown address 0x000819c4e834 (pc 0x00000006b2e8 bp 0x003fce274270 sp 0x003fce274160 T0)
        ==757633==The signal is caused by a WRITE memory access.
            #0 0x6b2e8 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x639d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==757633==ABORTING
2023-03-07 21:29 linux-riscv64-unmatched go@b675a75c misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (113.40s)
    --- FAIL: TestASAN/asan_global5 (6.26s)
        asan_test.go:97: /tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2301691877/asan_global5 exited with exit status 1
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==759402==ERROR: AddressSanitizer: SEGV on unknown address 0x00081a264830 (pc 0x0000001275c0 bp 0x003fd1324250 sp 0x003fd1324140 T0)
            ==759402==The signal is caused by a WRITE memory access.
                #0 0x1275c0 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a862 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
    --- FAIL: TestASAN/asan_global3_fail (8.11s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN1254775838/asan_global3_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==759476==ERROR: AddressSanitizer: SEGV on unknown address 0x00081c562630 (pc 0x000000129f94 bp 0x003fe2b13250 sp 0x003fe2b13140 T0)
            ==759476==The signal is caused by a WRITE memory access.
                #0 0x129f94 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a972 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==760756==ERROR: AddressSanitizer: SEGV on unknown address 0x00081b01d030 (pc 0x000000129ccc bp 0x003fd80e8260 sp 0x003fd80e8150 T0)
            ==760756==The signal is caused by a WRITE memory access.
                #0 0x129ccc in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a972 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==760756==ABORTING
go tool dist: Failed: exit status 1
2023-03-07 22:52 linux-riscv64-unmatched go@457fd1d5 misc/cgo/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (29.59s)
    asan_test.go:140: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.4187861058/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==883445==ERROR: AddressSanitizer: SEGV on unknown address 0x000819c4d430 (pc 0x00000006b2e8 bp 0x003fce26a260 sp 0x003fce26a150 T0)
        ==883445==The signal is caused by a WRITE memory access.
            #0 0x6b2e8 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
            #1 0x639d2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
        ==883445==ABORTING
2023-03-07 22:52 linux-riscv64-unmatched go@457fd1d5 misc/cgo/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (116.09s)
    --- FAIL: TestASAN/asan_unsafe_fail2 (9.82s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2185002360/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==885239==ERROR: AddressSanitizer: SEGV on unknown address 0x00081ab5722c (pc 0x000000127298 bp 0x003fd5ab9240 sp 0x003fd5ab9130 T0)
            ==885239==The signal is caused by a WRITE memory access.
                #0 0x127298 in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a862 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
    --- FAIL: TestASAN/asan1_fail (10.98s)
        asan_test.go:95: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2695333678/asan1_fail` exited without expected memory access error
            heap-use-after-free; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==885309==ERROR: AddressSanitizer: SEGV on unknown address 0x00081971dc30 (pc 0x00000012792a bp 0x003fcb8ee250 sp 0x003fcb8ee140 T0)
            ==885309==The signal is caused by a WRITE memory access.
                #0 0x12792a in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a922 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

...
            =================================================================
            ==886617==ERROR: AddressSanitizer: SEGV on unknown address 0x00081c406630 (pc 0x000000129ccc bp 0x003fe2033250 sp 0x003fe2033140 T0)
            ==886617==The signal is caused by a WRITE memory access.
                #0 0x129ccc in x_cgo_init /_/runtime/cgo/gcc_linux_riscv64.c:56
                #1 0x6a972 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/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
            ==886617==ABORTING
go tool dist: Failed: exit status 1

watchflakes

@mknyszek mknyszek modified the milestones: Go1.21, Backlog Jun 9, 2023
@hack3ric
Copy link

I was investigating this issue and found kRiscv64_ShadowOffset is changed in libsanitizer/asan/asan_mapping.h to 0xd55550000 while value in gcc/config/riscv/riscv.cc remains the original value of 0x20000000 (1<<29).

This issue is fixed in gcc-mirror/gcc@21a0762 (one day before I discovered the issue and gcc-mirror then was out-of-date), and all Go tests passed with cherry-picked GCC 13.1.1 on Arch Linux riscv64.

Sorry for the late response. Thanks @mengzhuo and @yuzibo for their help, and @andreas-schwab for fixing. The issue may be closed now unless I missed something.

hack3ric added a commit to hack3ric/archriscv-packages that referenced this issue Jun 11, 2023
Fix libasan error for downstream projects such as Go.

Discussion: golang/go#57691
felixonmars pushed a commit to felixonmars/archriscv-packages that referenced this issue Jun 11, 2023
Fix libasan error for downstream projects such as Go.

Discussion: golang/go#57691
@zhsj
Copy link
Contributor Author

zhsj commented Jun 25, 2023

Confirmed. It's also fixed in gcc 12.

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- goos == "linux" && goarch == "riscv64" && log ~ `AddressSanitizer:DEADLYSIGNAL`
2023-08-23 21:37 linux-riscv64-unmatched go@27631460 cmd/cgo/internal/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (34.89s)
    asan_test.go:148: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.2109883400/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==126796==ERROR: AddressSanitizer: SEGV on unknown address 0x00081881d250 (pc 0x00000006cb92 bp 0x003fc40e92f0 sp 0x003fc40e9250 T0)
        ==126796==The signal is caused by a WRITE memory access.
            #0 0x6cb92 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
            #1 0x6d078 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
            #2 0x65882 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

        AddressSanitizer can not provide additional info.
        SUMMARY: AddressSanitizer: SEGV /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89 in _cgo_set_stacklo
        ==126796==ABORTING
2023-08-23 21:37 linux-riscv64-unmatched go@27631460 cmd/cgo/internal/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (109.00s)
    --- FAIL: TestASAN/asan_unsafe_fail2 (5.22s)
        asan_test.go:101: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN2037996502/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==128597==ERROR: AddressSanitizer: SEGV on unknown address 0x00081be2964c (pc 0x000000127bde bp 0x003fdf14b2d0 sp 0x003fdf14b230 T0)
            ==128597==The signal is caused by a WRITE memory access.
                #0 0x127bde in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x12811c in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
...
    --- FAIL: TestASAN/asan1_fail (6.28s)
        asan_test.go:101: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN4118426119/asan1_fail` exited without expected memory access error
            heap-use-after-free; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==128670==ERROR: AddressSanitizer: SEGV on unknown address 0x00081d4cfa4c (pc 0x0000001282c8 bp 0x003fea67d2e0 sp 0x003fea67d240 T0)
            ==128670==The signal is caused by a WRITE memory access.
                #0 0x1282c8 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x128806 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
                #2 0x6d29a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
            =================================================================
            ==129951==ERROR: AddressSanitizer: SEGV on unknown address 0x00081c9bda4c (pc 0x00000006eb32 bp 0x003fe4ded2e0 sp 0x003fe4ded240 T0)
            ==129951==The signal is caused by a WRITE memory access.
                #0 0x6eb32 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x6f018 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
                #2 0x68552 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89 in _cgo_set_stacklo
            ==129951==ABORTING

watchflakes

@gopherbot gopherbot reopened this Aug 24, 2023
@github-project-automation github-project-automation bot moved this from Done to In Progress in Go Compiler / Runtime Aug 24, 2023
@mengzhuo
Copy link
Contributor

The libasan of debian port is not fixed in 20221225T084846Z, I will lock the version of libasan in visionfive2 builder.

Closed.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Go Compiler / Runtime Aug 24, 2023
@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- goos == "linux" && goarch == "riscv64" && log ~ `AddressSanitizer:DEADLYSIGNAL`
2023-09-05 16:41 linux-riscv64-unmatched go@a40404da cmd/cgo/internal/testsanitizers.TestASANLinkerX (log)
--- FAIL: TestASANLinkerX (37.17s)
    asan_test.go:148: /tmp/workdir-host-linux-riscv64-unmatched/tmp/.1680897648/main.exe exited with exit status 1
        AddressSanitizer:DEADLYSIGNAL
        =================================================================
        ==153754==ERROR: AddressSanitizer: SEGV on unknown address 0x00081dd5a650 (pc 0x00000006cb32 bp 0x003feead32f0 sp 0x003feead3250 T0)
        ==153754==The signal is caused by a WRITE memory access.
            #0 0x6cb32 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
            #1 0x6d018 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
            #2 0x65822 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

        AddressSanitizer can not provide additional info.
        SUMMARY: AddressSanitizer: SEGV /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89 in _cgo_set_stacklo
        ==153754==ABORTING
2023-09-05 16:41 linux-riscv64-unmatched go@a40404da cmd/cgo/internal/testsanitizers.TestASAN (log)
--- FAIL: TestASAN (111.41s)
    --- FAIL: TestASAN/asan_unsafe_fail2 (4.95s)
        asan_test.go:101: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN255164592/asan_unsafe_fail2` exited without expected memory access error
            use-after-poison; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==155517==ERROR: AddressSanitizer: SEGV on unknown address 0x000819a24e4c (pc 0x000000127b8e bp 0x003fcd1272d0 sp 0x003fcd127230 T0)
            ==155517==The signal is caused by a WRITE memory access.
                #0 0x127b8e in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x1280cc in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
...
    --- FAIL: TestASAN/asan_global3_fail (6.91s)
        asan_test.go:101: `/tmp/workdir-host-linux-riscv64-unmatched/tmp/TestASAN3978096020/asan_global3_fail` exited without expected memory access error
            global-buffer-overflow; got failure
            AddressSanitizer:DEADLYSIGNAL
            =================================================================
            ==155605==ERROR: AddressSanitizer: SEGV on unknown address 0x00081cacbc4c (pc 0x00000012a8a2 bp 0x003fe565e2d0 sp 0x003fe565e230 T0)
            ==155605==The signal is caused by a WRITE memory access.
                #0 0x12a8a2 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x12ade0 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
                #2 0x6d29a in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34
...
            =================================================================
            ==156889==ERROR: AddressSanitizer: SEGV on unknown address 0x00081c7bec4c (pc 0x00000006ead2 bp 0x003fe3df62e0 sp 0x003fe3df6240 T0)
            ==156889==The signal is caused by a WRITE memory access.
                #0 0x6ead2 in _cgo_set_stacklo /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89
                #1 0x6efb8 in x_cgo_init /_/GOROOT/src/runtime/cgo/gcc_linux.c:23
                #2 0x684f2 in runtime.rt0_go /tmp/workdir-host-linux-riscv64-unmatched/go/src/runtime/asm_riscv64.s:34

            AddressSanitizer can not provide additional info.
            SUMMARY: AddressSanitizer: SEGV /_/GOROOT/src/runtime/cgo/gcc_libinit.c:89 in _cgo_set_stacklo
            ==156889==ABORTING

watchflakes

@gopherbot gopherbot reopened this Sep 8, 2023
@github-project-automation github-project-automation bot moved this from Done to In Progress in Go Compiler / Runtime Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-riscv Issues solely affecting the riscv64 architecture. compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Linux
Projects
Status: In Progress
Status: Done
Development

No branches or pull requests

12 participants