Skip to content

fix(runtime): expose a C function missing at runtime as undefined instead of asserting - #498

Merged
edusperoni merged 1 commit into
mainfrom
fix/missing-c-function-symbol
Oct 9, 2026
Merged

edusperoni merged 1 commit into
mainfrom
fix/missing-c-function-symbol

Conversation

@edusperoni

@edusperoni edusperoni commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What is the current behavior?

When metadata lists a C function that the running OS or the linked binary doesn't export (for example a function from a newer SDK, a weak-linked framework, or a stripped symbol), reading that global aborts the app through tns::Assert in MetadataBuilder::GlobalPropertyGetter. Feature detection such as typeof SomeCFunction === "undefined" crashes too.

What is the new behavior?

The getter logs Unable to load "<name>" function and declines, the same way missing data symbols (MetaType::Var) already behave:

  • typeof SomeCFunction is "undefined"
  • "SomeCFunction" in global is false
  • calling it throws a ReferenceError instead of crashing

Nothing is cached for a missing symbol, so a later lookup still re-checks.

Tests

Adds TNSFunctionMissingAtRuntime to TestFixtures/Functions/TNSFunctions.h. It is declared but never defined, so it lands in the metadata but not in the binary. A new ApiTests.js case asserts on all three behaviors listed above.

Suite: 1744 passed, 0 failed on an iOS 26.3 simulator.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of functions that are listed in metadata but unavailable at runtime. They are no longer exposed as globals, and attempts to call them report a reference error instead of triggering an internal assertion. Other global metadata behavior is unchanged.

…tead of asserting

Metadata can list a C function the running OS or linked binary doesn't export
(newer SDK, weak-linked or stripped symbol). Reading such a global hit
tns::Assert in the global property getter and aborted the app, so even
`typeof SomeCFunction === "undefined"` crashed. The getter now logs and
declines, matching how missing data symbols already behave, so the global
reads as undefined, `in` reports false, and a call throws a ReferenceError.

Suite 1744/0 on an iOS 26.3 simulator.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e10433a3-5912-4ac8-abc4-8aef23912bee
📥 Commits

Reviewing files that changed from the base of the PR and between c036f33 and f652d0b.

📒 Files selected for processing (3)
  • NativeScript/runtime/MetadataBuilder.mm
  • TestFixtures/Functions/TNSFunctions.h
  • TestRunner/app/tests/ApiTests.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The runtime now logs and declines interception when a metadata function’s symbol cannot be loaded. A test fixture declares a function without a runtime definition, and an API test checks its global availability and call behavior.

Changes

Missing Metadata Function

Layer / File(s) Summary
Handle missing function symbols
TestFixtures/Functions/TNSFunctions.h, NativeScript/runtime/MetadataBuilder.mm, TestRunner/app/tests/ApiTests.js
The fixture declares TNSFunctionMissingAtRuntime without defining it. When the runtime cannot load a metadata function’s symbol, it logs the failure and declines interception instead of asserting. The API test checks that the function is undefined, absent from global, and raises ReferenceError when called.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: nathanwalker

Merge Risk: ⚪ Minimal · up to f652d

Missing metadata-listed C functions are treated as absent globals rather than aborting the app. No concrete merge blocker was established; the change appears ready for normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main runtime change: missing C functions become undefined instead of triggering an assertion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the missing name,
No symbol waits, no assert flame.
The global stays without a claim,
A call brings ReferenceError fame,
Then hops along, pleased with the change.

Comment @coderabbitai help to get the list of available commands.

@edusperoni
edusperoni merged commit 91630ca into main Oct 9, 2026
10 checks passed
@edusperoni
edusperoni deleted the fix/missing-c-function-symbol branch October 9, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant