runtime: SIGSEGV in runtime.pageIndexOf when loading plugin on riscv64 #73283
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.
Milestone
It appears that in certain conditions on riscv64, the runtime’s memory allocator miscomputes the arena pointer for new spans, causing
pageIndexOf
to return an invalid pointer that is later used ininitSpan
. This leads to a segmentation fault. I believe this is a bug in the runtime memory allocation logic onriscv64
.I have observed a segmentation fault when loading a plugin on a riscv64 system using Go 1.24.1. The crash occurs in the memory allocator, specifically within the
runtime.pageIndexOf
function, which is called fromruntime.(*mheap).initSpan
.The error indicates that the arena pointer computed by
pageIndexOf
is invalid. In our case, the register t1 (which holds the arena pointer) is set to0x1112b008c0404440
, which does not appear to be a canonical, properly mapped address. The backtrace is as follows:The plugin loads and begins to allocate memory (in our case during the plugin initialization I allocate a significant memory block). When a new span is allocated, its base address (in our case, approximately
273469956096
) is passed toruntime.pageIndexOf
. The computed arena pointer in registert1
then turns out to be0x1112b008c0404440
, an address that does not fall within a proper arena mapping. This leads to a segmentation fault when the runtime attempts to update the arena’s data structures.I have tried varying the memory allocation size in the plugin’s initialization (e.g., allocating 65MB), and the crash consistently appears when the allocation pushes the span’s base into an uninitialized arena slot. I suspect that this bug manifests under high memory pressure or when spans are allocated across arena boundaries.
Environment
riscv64
Detailed infomation
I'm new to Go and have only captured some basic information. If more details are needed, feel free to ping me, I'm more than happy to provide them.
The text was updated successfully, but these errors were encountered: