Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: nil pointer dereference crash when building with an Android NDK toolchain #34788
The only requisite is a version of Go and the NDK r18 installed at
Below is the script to reproduce the crash:
Here is the output from Go master:
And from 1.13.1:
It seems like the line it fails on is an error line, so I assume this should error gracefully instead of panicking. I'm not sure though.
My intuition is that the build should succeed; this project in question (@grote's) was previously using Go 1.11.x without an issue. If the build should succeed here too, I'd suggest we backport a fix for 1.13.x.
This appears to be related to the recent changes to the way TLS works on Android (see issue 29674).
As part of Go 1.13 we transitioned to a new TLS access sequence for Android that loads up the newly defined "runtime.tls_g" symbol. If you compile a Go source file with
GOARCH=386 GOOS=android go tool compile x.go
Here is what the prolog looks like (from go tool objdump):
Note the R_TLS_LE relocation. Here is the description from
At the point of the crash in the linker, we're trying to process an R_TLS_LE relocation on a text symbol (regular Go function), but the relocation's Xsym field is nil, so it tries to execute this line:
Errorf(s, "missing xsym in relocation %#v %#v", r.Sym.Name, s)
which faults because r.Sym is also nil. The code that ordinarily would have filled the r.Sym is here:
however ctxt.Tlsg is now also nil due to CL 169618.
Not quite sure what the right fix is here-- as I understand it we are no longer using the "local exec" model for TLS (is this right?) in which case we should not have the R_TLS_RE in this case?