beeware / beeware/rubicon-objc

Improve error handling when a required selector isn't defined

Open
#94 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
301
Forks
70
Avg merge
1d 8h
Merged PRs (30d)
18

Description

At present, if a class doesn't implement a required selector, the Objective C runtime raises a hard crash. For example:
```
2017-12-29 12:09:23.220 python[22410:8656994] -[TogaCanvas window]: unrecognized selector sent to instance 0x7fad6342b1b0
2017-12-29 12:09:23.228 python[22410:8656994] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TogaCanvas window]: unrecognized selector sent to instance 0x7fad6342b1b0'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffaa5022cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffbf31b48d objc_exception_throw + 48
2 CoreFoundation 0x00007fffaa583f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fffaa474755 ___forwarding___ + 1061
4 CoreFoundation 0x00007fffaa4742a8 _CF_forwarding_prep_0 + 120
5 AppKit 0x00007fffa7f4ffcf -[NSView addSubview:] + 59
6 _ctypes.cpython-35m-darwin.so 0x000000010b9602ef ffi_call_unix64 + 79
7 ??? 0x00007fff55020830 0x0 + 140734619584560
)
libc++abi.dylib: terminating with uncaught exception of type NSException
```
It should be possible to avoid the hard crash by implementing `doesNotRecognizeSelector:` on the base ObjInstance. This should provide a better opportunity to manage or report the crash than showing a memory dump.

Contributor guide

Open the contributing guide

Research direction

Start at the base ObjInstance implementation and inspect how Objective-C selector failures are currently surfaced. Reproduce the missing-required-selector case described in the issue and trace doesNotRecognizeSelector:. Done means the failure is handled through that entry point instead of terminating with the raw runtime crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, python
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.