Crashes on Android when compiled with Go 1.23.5

I am compiling Syncthing for Android to develop an app as part of the Syncthing Tray project. I am usually just blindly using the Go version provided by Arch Linux, currently that is Go 1.23.5. It works - on my phone with Android 14 (aarch64) and the Android emulator with Android 15 (x86_64) I can run my app which in turn can run Syncthing (within the same process as I built Syncthing as library).

I noticed that it doesn’t work on my older phone with Android 10 (aarch64) and also not on the Android emulator with Android 10 (x86_64). The error log doesn’t say much:

2025-01-22 23:57:22.177  8343-8377  Qt                      io.github.martchus.syncthingtray     I  qt started
2025-01-22 23:57:22.189  8343-8381  libc                    io.github.martchus.syncthingtray     A  Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 8381 (qtMainLoopThrea), pid 8343 (s.syncthingtray)
2025-01-22 23:57:22.201  8343-8343  SyncthingActivity       io.github.martchus.syncthingtray     I  Starting
2025-01-22 23:57:22.202  8343-8343  SyncthingActivity       io.github.martchus.syncthingtray     I  Resuming
2025-01-22 23:57:22.229  8391-8391  DEBUG                   pid-8391                             A  pid: 8343, tid: 8381, name: qtMainLoopThrea  >>> io.github.martchus.syncthingtray <<<
2025-01-22 23:57:22.229  8391-8391  DEBUG                   pid-8391                             A        #00 pc 000000000065d20e  /data/app/io.github.martchus.syncthingtray-hAz0hxna8xVgPw-Qly4PwA==/lib/x86_64/libsyncthinginternal.so (offset 0x5d9000)

The startup of Qt is logged at which point it loads native libraries which means loading also Syncthing build as shared library. And there it crashes, presumably because Syncthing (or rather something in its Go software stack) tries to invoke an invalid/disallowed syscall.

Everything works also under Android 10 when I do not link against the Syncthing library. So I am sure it must be the culprit.

I am already adding --target=x86_64-none-linux-android21 to all C/C++ compiler invocations by setting CGO_CFLAGS and other variables. To be super sure I also tried hardcoding CC=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang and CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++. However, it didn’t make a difference and I am sure the Android API level for native compilations is set correctly.

This leaves the compilation of Go code. So I tried an older Go version:

$ go install golang.org/dl/go1.21.13@latest
$ $GOPATH/bin/go1.21.13 download
…
Success. You may now run 'go1.21.13'
$GOPATH/bin/go1.21.13 version
go version go1.21.13 linux/amd64
…

Then I re-configured/re-built Syncthing Tray (and the Syncthing library) with that Go version (just for my own record, I was using: cmake --preset arch-android -DGO_BIN=$GOPATH/bin/go1.21.13 && cmake --build --preset arch-android). The resulting APK then worked under Android 10 in the emulator. (I haven’t tested it on my older phone yet.)

Then I changed it back to /usr/bin/go (this is 1.13.5 as provided by Arch Linux) to be sure the problem has not just ceased due to some cache wiping when changing the Go version. Considering it immediately stopped to work again I don’t think this is the case.

Then I changed the binary to $GOPATH/bin/go1.22.11 (installed using the same steps as shown for 1.21.13) and it worked again.

This suggests that Go introduced the unconditional usage of a syscall as of version 1.23.? and that syscall is not available under older Android versions. Not sure what the new minimum Android version is with that syscall (but the new minimum must be in the range of (10, 14]).

This might be an intentional change. Unfortunately I couldn’t find anything about the minimum Android version required by Go, e.g. Go Wiki: Minimum Requirements - The Go Programming Language doesn’t mention Android at all. I also haven’t found much via Google.

@Catfriend1 If you’re reading this, did you also run into this problem when testing the fork app? What version of Go and Android have you been testing on?

After searching directly on GitHub (the Google search is really not great for this kind of issues) I found x/mobile: seccomp prevented call to disallowed arm64 system call 434 · Issue #70508 · golang/go · GitHub. This is probably the culprit - even though the problem is not specific to arm64 and the mentioned Go version mentioned at the beginning is confusing.

@Catfriend1 It also looks like the issue only occurs when building a library. So it is probably not relevant to you.

1 Like

The Go requirement is on the kernel, not android - at least I am not aware of android reqs. And unfortunately the linux kernel requirements aren’t that clearcut on the linked minimum req. page for the arches typically present on phones: Go Wiki: Minimum Requirements - The Go Programming Language

Also there were some arm related changes in go1.23 to target different versions, however the default should not have changed: Go Wiki: Minimum Requirements - The Go Programming Language

Probably worth checking comparing arch and kernel versions between devices that work and don’t. On android there’s also the chance that your vendor bastardizes the kernel, but I think that’s rare.

1 Like

Never mind me, I didn’t see your second comment. That seems like a very plausible reason indeed.

That’s true as we’re talking about syscalls here. I was still focusing on Android versions because that’s simply the level I can easily do tests with. (Additionally, it is not just about the kernel version but also its configuration, e.g. the SELinux config - and that can differ from one concrete system to another concrete system and thus from Android version to Android version.)

Thanks for looking into it, though.


Considering the current upstream solution is not really helpful in my use case I’m trying to handle/ignore the signal now.


EDIT: I was now also able to workaround the issue by simply ignoring the signal (Workaround Go issue causing the app to crash on older Android versions · Martchus/syncthingtray@a81e6d4 · GitHub). This is not nice because it’ll potentially hide other similar issues but it is probably the best I can do for now.