-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/mobile: accessing field on nil on iOS raises exception instead of panicking (gomobile) #23511
Comments
Have you tried to run your program outside the (Xcode) debugger or simply continuing execution after the exception is raised? I believe that the Go runtime will catch the exception and enable your recover to catch the panic. |
Ah, interesting! I hadn't tried running it outside of Xcode. Continuing execution in Xcode doesn't work (just stays at the same exception), but if I run outside of Xcode, catching the panic works and the program functions normally. So it seems like the issue is that Xcode's debugger is probably installing a signal handler that conflicts with how panics get caught. OK, so to summarize then, there are two distinct ways this is a (minor) problem:
|
I found it will crash when it run on RAM32 device like iPhone 5c, even not running outside of Xcode |
@HaidyCao, is that reproducible on an arm64 device running arm32 gomobile? You can restrict gomobile bind with the |
@eliasnaur Yes. I tried: My go version is go1.11 and gomobile is newest. my test go file:
One other thing. When I catched a panic in go code, iOS system still report a crash log, but app not crash. crash log:
|
I see. So your app is actually able to continue (outside Xcode) if you catch the panic? If so, that's expected and not likely to change in the near future. Perhaps the Go runtime will need to use mach exception handlers for for panics instead of using the posix signal functions. |
It just occurred to me that the |
Thank you. I tried use Catch crash report is another ARM64 device and it able to continue (outside Xcode) if catch the panic. |
I hit this today, a simple example:
If you disable I have not found a way to catch and ignore this in swift. It would be ideal if |
Is there any update regarding this problem? This is still an issue on go 1.16.15 and most recent gomobile on iOS (arm64). |
FWIW, I've also set up a demo project here for Swift macOS showcasing this issue: But the problem as far as I can tell is not really in the go runtime, rather that the debugger |
The spec says accessing a field (
x.foo
) should panic ifx
isnil
, but it seems that in an iOS library built with gomobile, the result is an EXC_BAD_ACCESS exception being raised.Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Here's an example that works fine in a regular Go program but the equivalent compiled into an iOS app crashes: https://play.golang.org/p/KsIyVll7NE0.
What did you expect to see?
Accessing a field on nil panics, and is handled by a surrounding defer/recover block.
What did you see instead?
Accessing a field on nil raises a native exception, crashing the program unrecoverably.
System details
The text was updated successfully, but these errors were encountered: