go: x/mobile: iOS framework, app crashes on launch for 1.18

What version of Go are you using (go version)?

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

$ go env 
GOOS="darwin"
GOARCH="amd64"
...

What did you do?

  1. Upgraded to version 1.18.
  2. Build iOS framework for iOS app.
$ gomobile bind -target=ios -o Frameworks/helper.framework
  1. iOS framework is built with no issues.
  2. Attach framework and start Flutter iOS example app:
$ cd example
$ flutter run

What did you expect to see?

App running happily.

What did you see instead?

App tried to launch, white background becomes visible, but closes abruptly. Here’s the console log:

Running pod install...                                           1,031ms
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         5.8s
Xcode build done.                                           26.1s
(lldb) signal 16 received on thread with no signal stack
fatal error: non-Go code disabled sigaltstack


runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x1df14ad48
stack: frame={sp:0x130040810, fp:0x1300408e0} stack=[0x1300386f0,0x130040af0)
0x0000000130040710:  0x0000000130040768  0x0000000000000000 
0x0000000130040720:  0x0000000000000000  0x0000000000000000 
0x0000000130040730:  0x0000000000000000  0x0000000000000000 
0x0000000130040740:  0x0000000000000000  0x0000000000000000 
0x0000000130040750:  0x0000000000000004  0x00000001300407d8 
0x0000000130040760:  0x0000000100dde16c <runtime.sigtrampgo+0x000000000000001c>  0x0000000100000010 
0x0000000130040770:  0x00000001010f85c0  0x0000000130040798 
0x0000000130040780:  0x0000000000000000  0x0000000000000000 
0x0000000130040790:  0x0000000000000000  0x0000000000000000 
0x00000001300407a0:  0x0000000000000000  0x0000000000000000 
0x00000001300407b0:  0x0000000000000000  0x0000000000000000 
0x00000001300407c0:  0x00000001300021a0  0x0000000130040910 
0x00000001300407d0:  0x0000000130040978  0x0000000130040808 
0x00000001300407e0:  0x0000000100ddd7c4 <runtime.sigtramp+0x0000000000000074>  0x0000000000000010 
0x00000001300407f0:  0x0000000130040910  0x0000000130040978 
0x0000000130040800:  0x0000000000000000  0x0000000130040900 
0x0000000130040810: <0x00000001df14ad48  0x0000000000000010 
0x0000000130040820:  0x0000000130040910  0x0000000130040978 
0x0000000130040830:  0x855ee83f1200706a  0x0000000130040978 
0x0000000130040840:  0x00000001f685d000  0x00000001011292f4 
0x0000000130040850:  0x0000000000000000  0x0000000000000000 
0x0000000130040860:  0x0000000000000000  0x00000001010dff80 
0x0000000130040870:  0x0000000100f8b670  0x00000001300021a0 
0x0000000130040880:  0x0000000130040808  0x0000000000000000 
0x0000000130040890:  0x0000000000000000  0x0000000000000000 
0x00000001300408a0:  0x0000000000000000  0x0000000000000000 
0x00000001300408b0:  0x0000000000000000  0x0000000000000000 
0x00000001300408c0:  0x0000000000000000  0x0000000000000000 
0x00000001300408d0:  0x0000000000000000  0x0000000000000000 
0x00000001300408e0: >0x00000001011292f4  0x0000000000000003 
0x00000001300408f0:  0x000000000000007d  0x0000000130040f58 
0x0000000130040900:  0x0000000130040d58  0x0000000100daf4fc <runtime.init.5+0x000000000000002c> 
0x0000000130040910:  0x0000000000000010  0x0000000000000000 
0x0000000130040920:  0x0000000000000000  0x0000000100dcc180 <runtime.funcMaxSPDelta+0x0000000000000030> 
0x0000000130040930:  0x0000000000000000  0x0000000000000000 
0x0000000130040940:  0x0000000000000000  0x0000000000000000 
0x0000000130040950:  0x0000000000000000  0x0000000000000000 
0x0000000130040960:  0x0000000000000000  0x0000000000000000 
0x0000000130040970:  0x0000000000000000  0x0000000000000000 
0x0000000130040980:  0x0000000130040910  0x0000000000000000 
0x0000000130040990:  0x0000000000000000  0x0000000000000000 
0x00000001300409a0:  0x0000000000000330  0x00000001300409b0 
0x00000001300409b0:  0x000000010108e3c8  0x0000000092000007 
0x00000001300409c0:  0x000000010108e3b8  0x00000001010e4880 
0x00000001300409d0:  0x000000000006dd90  0x00000001010030c0 
runtime.throw({0x100f35dbf?, 0x130044000?})
        /usr/local/go/src/runtime/panic.go:992 +0x50
runtime.noSignalStack(0x10)
        /usr/local/go/src/runtime/signal_unix.go:994 +0x60
runtime.adjustSignalStack(0x10, 0x1010f85c0, 0x130040798)
        /usr/local/go/src/runtime/signal_unix.go:575 +0x24c
runtime.sigtrampgo(0x10, 0x130040910, 0x130040978)
        /usr/local/go/src/runtime/signal_unix.go:467 +0x174
runtime.sigtrampgo(0x10, 0x130040910, 0x130040978)
        <autogenerated>:1 +0x1c
runtime: unexpected return pc for runtime.sigtramp called from 0x1df14ad48
stack: frame={sp:0x130040810, fp:0x1300408e0} stack=[0x1300386f0,0x130040af0)
0x0000000130040710:  0x0000000130040768  0x0000000000000000 
0x0000000130040720:  0x0000000000000000  0x0000000000000000 
0x0000000130040730:  0x0000000000000000  0x0000000000000000 
0x0000000130040740:  0x0000000000000000  0x0000000000000000 
0x0000000130040750:  0x0000000000000004  0x00000001300407d8 
0x0000000130040760:  0x0000000100dde16c <runtime.sigtrampgo+0x000000000000001c>  0x0000000100000010 
0x0000000130040770:  0x00000001010f85c0  0x0000000130040798 
0x0000000130040780:  0x0000000000000000  0x0000000000000000 
0x0000000130040790:  0x0000000000000000  0x0000000000000000 
0x00000001300407a0:  0x0000000000000000  0x0000000000000000 
0x00000001300407b0:  0x0000000000000000  0x0000000000000000 
0x00000001300407c0:  0x00000001300021a0  0x0000000130040910 
0x00000001300407d0:  0x0000000130040978  0x0000000130040808 
0x00000001300407e0:  0x0000000100ddd7c4 <runtime.sigtramp+0x0000000000000074>  0x0000000000000010 
0x00000001300407f0:  0x0000000130040910  0x0000000130040978 
0x0000000130040800:  0x0000000000000000  0x0000000130040900 
0x0000000130040810: <0x00000001df14ad48  0x0000000000000010 
0x0000000130040820:  0x0000000130040910  0x0000000130040978 
0x0000000130040830:  0x855ee83f1200706a  0x0000000130040978 
0x0000000130040840:  0x00000001f685d000  0x00000001011292f4 
0x0000000130040850:  0x0000000000000000  0x0000000000000000 
0x0000000130040860:  0x0000000000000000  0x00000001010dff80 
0x0000000130040870:  0x0000000100f8b670  0x00000001300021a0 
0x0000000130040880:  0x0000000130040808  0x0000000000000000 
0x0000000130040890:  0x0000000000000000  0x0000000000000000 
0x00000001300408a0:  0x0000000000000000  0x0000000000000000 
0x00000001300408b0:  0x0000000000000000  0x0000000000000000 
0x00000001300408c0:  0x0000000000000000  0x0000000000000000 
0x00000001300408d0:  0x0000000000000000  0x0000000000000000 
0x00000001300408e0: >0x00000001011292f4  0x0000000000000003 
0x00000001300408f0:  0x000000000000007d  0x0000000130040f58 
0x0000000130040900:  0x0000000130040d58  0x0000000100daf4fc <runtime.init.5+0x000000000000002c> 
0x0000000130040910:  0x0000000000000010  0x0000000000000000 
0x0000000130040920:  0x0000000000000000  0x0000000100dcc180 <runtime.funcMaxSPDelta+0x0000000000000030> 
0x0000000130040930:  0x0000000000000000  0x0000000000000000 
0x0000000130040940:  0x0000000000000000  0x0000000000000000 
0x0000000130040950:  0x0000000000000000  0x0000000000000000 
0x0000000130040960:  0x0000000000000000  0x0000000000000000 
0x0000000130040970:  0x0000000000000000  0x0000000000000000 
0x0000000130040980:  0x0000000130040910  0x0000000000000000 
0x0000000130040990:  0x0000000000000000  0x0000000000000000 
0x00000001300409a0:  0x0000000000000330  0x00000001300409b0 
0x00000001300409b0:  0x000000010108e3c8  0x0000000092000007 
0x00000001300409c0:  0x000000010108e3b8  0x00000001010e4880 
0x00000001300409d0:  0x000000000006dd90  0x00000001010030c0 
runtime.sigtramp()
        /usr/local/go/src/runtime/sys_darwin_arm64.s:243 +0x74


goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_arm64.s:1259 +0x4 fp=0x13005bfe0 sp=0x13005bfe0 pc=0x100ddcaf4


goroutine 1 [running, locked to thread]:
        goroutine running on other thread; stack unavailable
* thread #2, stop reason = signal SIGABRT
    frame #0: 0x00000001bebf69e8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1bebf69e8 <+8>:  b.lo   0x1bebf6a04               ; <+36>
    0x1bebf69ec <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bebf69f0 <+16>: mov    x29, sp
    0x1bebf69f4 <+20>: bl     0x1bebf2670               ; cerror_nocancel
Target 0: (Runner) stopped.
Installing and launching...                                        21.5s
Error launching application on iPhone.

iOS example app runs fine up to version 1.17.8 After upgrading to 1.18, building the framework, app launch failed.

Reverting to 1.17.8, and rebuilding the framework, app launch succeeds.

I saw a similar error log posted here: #47952

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I experience a similar error using cross-compiled golang for iOS (not via x/mobile), and the issue was due to GOOS=darwin instead of GOOS=ios on my compiles. This change in behavior started with https://go-review.googlesource.com/c/go/+/256917/

GOOS=ios was introduced in https://github.com/golang/go/commit/a413908dd064de6e3ea5b8d95d707a532bd3f4c8

For catalyst, x/mobile still uses GOOS=darwin https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L63-L65

I tried to create a minimal example. In doing so I realized that I was using an older version of the gomobile binary. For example, earlier, in running the command:

$ gomobile bind -target=ios -o Frameworks/helper.framework

In the latest version, it should have thrown the error:

gomobile: static framework name "Frameworks/helper.framework" missing .xcframework suffix

Furthermore, I noticed that the go.mod file has the maximum go version, but simply editing it to the new version didn’t work.

module example.com/helper
 
go 1.17
...

So I reinitialize the the go module:

$ go mod init example.com/helper 

so that it reflects the current version:

module example.com/helper
 
go 1.18
...

In the end, I wasn’t able to create a minimal example that can reproduce the error, But I was able to solve my current predicament by:

  1. Reinitializing the go module.
  2. Updating gomobile.

Thank you for your support.