Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
x/mobile: accessing field on nil on iOS raises exception instead of panicking (gomobile) #23511
The spec says accessing a field (
Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
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.
changed the title from
Accessing field on nil on iOS raises exception instead of panicking (gomobile)
x/mobile: accessing field on nil on iOS raises exception instead of panicking (gomobile)
Jan 23, 2018
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: