diff options
| author | Michael Pratt <mpratt@google.com> | 2026-03-31 16:34:59 -0400 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2026-04-02 09:58:36 -0700 |
| commit | 78d5260426899e934a4d680910b1484953e78087 (patch) | |
| tree | 720363c8910cf1a4cf3b6e8318b2cc4e7c463742 /src/runtime/proc.go | |
| parent | ef90a565b50af191c4f20b62770b084d6978a88d (diff) | |
| download | go-78d5260426899e934a4d680910b1484953e78087.tar.xz | |
runtime: use asmcgocall_no_g in libInit
libInit runs before rt0_go, which is where TLS setup occurs. Thus the
contents of the TLS may not be defined, so the g lookup in asmcgocall is
not safe.
Concretely, android-386 c-shared builds crash without this change
because asmcgocall reads an invalid non-zero g from the TLS.
Move libInit to a file limited to GOARCH that support c-archive or
c-shared so that only those require asmcgocall_no_g. In addition,
loong64 and s390x need asmcgocall_no_g implementations.
Fixes #78480.
Cq-Include-Trybots: luci.golang.try:gotip-linux-loong64,gotip-linux-s390x
Change-Id: I175e6d020339af89c9b576535d79c1e76a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761541
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 7e177c72cd..56971c7dbe 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -8153,24 +8153,3 @@ func doInit1(t *initTask) { t.state = 2 // initialization done } } - -// libInit is common startup code for most architectures when -// using -buildmode=c-archive or -buildmode=c-shared. -// -// May run with m.p==nil, so write barriers are not allowed. -// -//go:nowritebarrierrec -//go:nosplit -func libInit() { - // Synchronous initialization. - libpreinit() - - // Asynchronous initialization. - // Prefer creating a thread via cgo if it is available. - if _cgo_sys_thread_create != nil { - asmcgocall(_cgo_sys_thread_create, unsafe.Pointer(abi.FuncPCABIInternal(rt0_lib_go))) - } else { - const stackSize = 0x800000 // 8192KB - newosproc0(stackSize, unsafe.Pointer(abi.FuncPCABIInternal(rt0_lib_go))) - } -} |
