Skip to content

x/mobile: gomobile bind: Crash on android: dlopen failed: TLS symbol "(null)" in dlopened x86_64/libgojni.so using IE access model #69109

@marius-enlock

Description

@marius-enlock

Go version

go version go1.21.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/marius/.cache/go-build'
GOENV='/home/marius/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/marius/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/marius/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/marius/work/project/go.mod'
GOWORK='/home/marius/work/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build238633052=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I am creating a go library for Android that I use in React Native. The go library uses CGO (and has a as a dependency a static library that is built against android ndk llvm libc++ ), and also uses gRPC for communication with the server (However in the gRPC package I do not rely on TLS - I have a custom connection protocol, nor anywhere in the library I rely on TLS)

CC_FOR_TARGET=/home/marius/work/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android34-clang gomobile bind -target android/amd64 -androidapi 34 -o redactedd.aar ./mobile/

And then I load the .aar archive into a react native project in the respective android project, and created the library data bindings in Kotlin. The project compiles.

What did you see happen?

My Android Kotlin binding that loads the library compiles and I can build it from react native, but when loading it into the Android emulator (Pixel 3a API 34 x86_64) I get the following Crash:

--------- beginning of crash
08-28 18:23:13.711 11376 11425 E AndroidRuntime: FATAL EXCEPTION: create_react_context
08-28 18:23:13.711 11376 11425 E AndroidRuntime: Process: com.redactedmobile, PID: 11376
08-28 18:23:13.711 11376 11425 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: TLS symbol "(null)" in dlopened "/data/app/~~DwBiQaHdfiu5-dwMAj1Ulw==/com.redactedmobile-6XrWB7ekbVezJa8jWGp8QQ==/base.apk!/lib/x86_64/libgojni.so" referenced from "/data/app/~~DwBiQaHdfiu5-dwMAj1Ulw==/com.redactedmobile-6XrWB7ekbVezJa8jWGp8QQ==/base.apk!/lib/x86_64/libgojni.so" using IE access model
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1661)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at go.Seq.<clinit>(Seq.java:37)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at mobile.Mobile.<clinit>(Mobile.java:12)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at mobile.API.<clinit>(API.java:11)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.readactedmobile.Service.<init>(Service.kt:38)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.readactedmobile.ServicePackage.createNativeModules(Service.kt:27)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:35)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:40)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1510)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1481)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1392)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.lambda$runCreateReactContextOnNewThread$2(ReactInstanceManager.java:1161)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.$r8$lambda$PrBhihCbbAFk4ZReAALGanVLCyc(Unknown Source:0)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
08-28 18:23:13.711 11376 11425 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:1012)
08-28 18:23:14.543   418   418 E BpTransactionCompletedListener: Failed to transact (-32)
08-28 18:23:15.144   585  1658 E TaskPersister: File error accessing recents directory (directory doesn't exist?).

(I think a relevant document is this one: https://android.googlesource.com/platform/bionic/+/HEAD/docs/elf-tls.md)

What did you expect to see?

I was expecting for the react native program to not crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.mobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions