napi backend: unguarded selector dispatch turns unrecognized selector into process abort (NSException cannot unwind through ffi_call)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 40/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- ios, macos, objective-c
- Bereich
- backend
Rechercherichtung
Start in NativeScript/ffi/napi/ClassMember.mm, comparing tryObjCNapiDispatch and objcNativeCall against the respondsToSelector: guard in NativeScript/ffi/shared/jsi/NativeApiJsiInvocation.h (callObjCSelector). Reproduce by calling an instance member the receiver lacks, such as NSView.alloc().init().autoscroll, on a generic-napi macOS build. Done when that call throws a JS error instead of aborting, and resolveInstanceMethod: receivers still dispatch.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The napi backend dispatches objc_msgSend without verifying the receiver implements the selector. When metadata names a member the concrete receiver lacks — phantom metagen entries (#106), optional protocol members, SDK drift — the send enters ___forwarding___ → doesNotRecognizeSelector: → objc_exception_throw. The NSException cannot unwind through ffi_call's frames, so the process dies in __cxxabiv1::failed_throw (SIGABRT) before the surrounding @try/@catch — or any JS try/catch — can run.
The jsi backend already guards the same dispatch with respondsToSelector: (NativeScript/ffi/shared/jsi/NativeApiJsiInvocation.h, callObjCSelector). NativeScript/ffi/napi/ClassMember.mm — both tryObjCNapiDispatch (generated-invoker path) and objcNativeCall (ffi/super path) — does not.
Reproduction
macOS arm64, generic-napi build (-DTARGET_ENGINE=none -DNS_FFI_BACKEND=napi), metadata carrying a phantom member (see #106):
NSView.alloc().init().autoscroll
→ -[NSView isAutoscroll]: unrecognized selector sent to instance → libc++abi: terminating due to uncaught exception of type NSException → SIGABRT. More generally, any unrecognized selector reached through bridged dispatch aborts the process rather than raising a JS error.
Expected
Verify respondsToSelector: before self-targeted dispatch (one check per call) and rethrow the unrecognized-selector failure as a JS error — matching the jsi backend's tradeoff: forwarding-only receivers get a JS error, while resolveInstanceMethod: receivers still work because the check triggers method resolution.
Environment
NativeScript/runtimesmain(verified identical at5b697b39)- Generic napi backend,
TARGET_PLATFORM=macos, arm64; same code path ships in the iOS napi runtime.
- Vorherrschende Sprache
- C++
- Sterne
- 27
- Forks
- 5
- Ø Merge
- 5 T. 11 Std.
- Gemergte PRs (30 T.)
- 12
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/runtimes
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
NativeScript/runtimes#111 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 22/100
NativeScript/runtimes#110 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 32/100
NativeScript/runtimes#109 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
NativeScript/runtimes#108 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
NativeScript/runtimes#106 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in NativeScript/runtimes
Ähnliche Issues
-
documentation enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
QuantStack/git2cpp#203 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
BaptisteHudyma/Lamp-Da#588 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug macOS networking
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
docling-project/docling-parse#448 ·
Maintainer antworten meist innerhalb von 5 Tagen