bazel-contrib / bazel-contrib/rules_go

`fatal error: invalid function symbol table` when using cgo starting in go 1.21

Open
#4,091 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?
0.50.1

### What version of gazelle are you using?
0.38

### What version of Bazel are you using?
7.2.1

### Does this issue reproduce with the latest releases of all the above?
yes

### What did you do?
See https://github.com/DavidZbarsky-at/cgo-repro for repro

This was not an issue with go 1.20.1 but is an issue starting in 1.21
See https://github.com/google/skia/blob/main/.bazelrc#L41-L45 for another example in the wild

### What did you expect to see?
No-op binary runs correctly

### What did you see instead?
```
runtime: pcHeader: magic= 0xfffffff1 pad1= 0 pad2= 0 minLC= 4 ptrSize= 8 pcHeader.textStart= 0xab280 text= 0xaaaacbbab280 pluginpath=
fatal error: invalid function symbol table
runtime: panic before malloc heap initialized

runtime stack:
runtime.throw({0xaaaacbb2439a?, 0x0?})
GOROOT/src/runtime/panic.go:1023 +0x40 fp=0xffffc70b8870 sp=0xffffc70b8840 pc=0xaaaacbbde990
runtime.moduledataverify1(0xaaaacbcaaac0?)
GOROOT/src/runtime/symtab.go:532 +0x654 fp=0xffffc70b89a0 sp=0xffffc70b8870 pc=0xaaaacbbfcc84
runtime.moduledataverify(...)
GOROOT/src/runtime/symtab.go:518
runtime.schedinit()
GOROOT/src/runtime/proc.go:783 +0x68 fp=0xffffc70b8a20 sp=0xffffc70b89a0 pc=0xaaaacbbe2538
runtime.rt0_go()
src/runtime/asm_arm64.s:86 +0xa4 fp=0xffffc70b8a50 sp=0xffffc70b8a20 pc=0xaaaacbc0ddd4
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using the linked cgo repro with rules_go 0.50.1, Gazelle 0.38, Bazel 7.2.1, and Go 1.21, then compare it with Go 1.20.1. Start by tracing the reported runtime path through GOROOT/src/runtime/symtab.go, proc.go, and src/runtime/asm_arm64.s; done means the no-op binary runs without the invalid function symbol table error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.