Summary
For the following instruction set architectures:
The issue tracks the changes to be done in the Go Assembly implementation of cgocallbackg. The list is built from src/runtime/asm_*.s.
The goal is to convert the ABI0 calls to cgocallbackg into ABIInternal calls.
Background
As expected, the following program panics when an unpinned pointer is passed from Go to C.
The stack trace showing an auto-generated frame by the linker.
# cat -n main.c
1 #include <stdio.h>
2 #include "callbackErr.h"
3
4 int main(void) {
5 GoMap m = GoFoo();
6 (void)m;
7 return 0;
8 }
# cat -n callbackErr.go
1 package main
2
3 import (
4 "C"
5 )
6
7 //export GoFoo
8 func GoFoo() map[int]int {
9 return map[int]int{0: 1,}
10 }
11
12 func main() {
13 }
# go version
go version go1.26.2-X:nodwarf5 linux/amd64
# GOARCH=amd64 CC=gcc go build -buildmode=c-shared -o callbackErr.so callbackErr.go
# gcc -o main main.c callbackErr.so -Wl,-rpath,'$ORIGIN'
# ./main
[...]
goroutine 17 [running, locked to thread]:
panic({0x73b3380a0180?, 0x1dd6df238060?})
/usr/lib/go/src/runtime/panic.go:879 +0x16f
runtime.cgoCheckArg(0x73b3380a1400, 0x1dd6df2cc060, 0x0?, 0x0, 0x1)
/usr/lib/go/src/runtime/cgocall.go:659 +0x499
runtime.cgoCheckResult({0x73b3380a1400, 0x1dd6df2cc060})
/usr/lib/go/src/runtime/cgocall.go:829 +0x45
_cgoexp_35a35dd190e3_GoFoo(0x7ffebc378ba0)
/mnt/tmp/callbackErr.go:8 +0x6f
runtime.cgocallbackg1(0x73b338003000, 0x7ffebc378ba0, 0x0)
/usr/lib/go/src/runtime/cgocall.go:466 +0x2e5
runtime.cgocallbackg(0x73b338003000, 0x7ffebc378ba0, 0x0)
/usr/lib/go/src/runtime/cgocall.go:362 +0x132
runtime.cgocallbackg(0x73b338003000, 0x7ffebc378ba0, 0x0)
<autogenerated>:1 +0x2b
runtime.cgocallback(0x0, 0x0, 0x0)
/usr/lib/go/src/runtime/asm_amd64.s:1160 +0xcd
runtime.goexit({})
/usr/lib/go/src/runtime/asm_amd64.s:1771 +0x1
The call to cgocallbackg was done using the ABI0 convention, and the linker wrapped it into an ABIInternal call.
ABI0 is a stack-based ABI; ABIInternal is register-based. See the ABIInternal specifications.
Summary
For the following instruction set architectures:
not yet, see comment386amd64, CL 765581not yet, see commentarmarm64, CL 768780loong64not yet, see commentmips64xnot yet, see commentmipsxppc64xriscv64s390x, CL 773440The issue tracks the changes to be done in the Go Assembly implementation of
cgocallbackg. The list is built fromsrc/runtime/asm_*.s.The goal is to convert the ABI0 calls to
cgocallbackginto ABIInternal calls.Background
As expected, the following program panics when an unpinned pointer is passed from Go to C.
The stack trace showing an auto-generated frame by the linker.
The call to
cgocallbackgwas done using the ABI0 convention, and the linker wrapped it into an ABIInternal call.ABI0 is a stack-based ABI; ABIInternal is register-based. See the ABIInternal specifications.