Skip to content

Guard NSString.UTF8String against nil in ExecuTorchModule.mm#19712

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
metascroy:export-D105904682
May 21, 2026
Merged

Guard NSString.UTF8String against nil in ExecuTorchModule.mm#19712
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
metascroy:export-D105904682

Conversation

@metascroy
Copy link
Copy Markdown
Contributor

Summary:
Fix 8 sites in ExecuTorchModule.mm where -[NSString UTF8String] (returns
_Nullable) was passed directly into C++ Module APIs typed
const char *_Nonnull. On iOS Apple bindings these compile with
-Werror,-Wnullable-to-nonnull-conversion, so each site failed the build,
breaking messenger-jest-xcodestaging-iphonesimulator-{local,profile}-buck2
(298/280 consecutive failures since ~2026-05-12) and causing the iOS
pct_healthy regression tracked in T271188257.

Apply the standard fbobjc fallback pattern methodName.UTF8String ?: "" at
every affected call. Behavior is unchanged for any non-nil method name (the
common case); a nil/empty NSString now degenerates to an empty C string instead
of a null pointer, matching what the C++ API contract already required.

Affected call sites (all in
xplat/executorch/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm):

  • line 322 _module->load_method(...)
  • line 366 _module->load_method(..., cppMap)
  • line 380 _module->is_method_loaded(...)
  • line 384 _module->unload_method(...)
  • line 407 _module->method_meta(...)
  • line 552 _module->set_input(...)
  • line 592 _module->set_inputs(...)
  • line 635 _module->set_output(...)

The Messenger-owned sites in the same compilation are being addressed in
D105868578.

Differential Revision: D105904682

Summary:
Fix 8 sites in ExecuTorchModule.mm where `-[NSString UTF8String]` (returns
`_Nullable`) was passed directly into C++ `Module` APIs typed
`const char *_Nonnull`. On iOS Apple bindings these compile with
`-Werror,-Wnullable-to-nonnull-conversion`, so each site failed the build,
breaking `messenger-jest-xcodestaging-iphonesimulator-{local,profile}-buck2`
(298/280 consecutive failures since ~2026-05-12) and causing the iOS
pct_healthy regression tracked in T271188257.

Apply the standard fbobjc fallback pattern `methodName.UTF8String ?: ""` at
every affected call. Behavior is unchanged for any non-nil method name (the
common case); a nil/empty NSString now degenerates to an empty C string instead
of a null pointer, matching what the C++ API contract already required.

Affected call sites (all in
xplat/executorch/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm):
  - line 322  _module->load_method(...)
  - line 366  _module->load_method(..., cppMap)
  - line 380  _module->is_method_loaded(...)
  - line 384  _module->unload_method(...)
  - line 407  _module->method_meta(...)
  - line 552  _module->set_input(...)
  - line 592  _module->set_inputs(...)
  - line 635  _module->set_output(...)

The Messenger-owned sites in the same compilation are being addressed in
D105868578.

Differential Revision: D105904682
@metascroy metascroy requested a review from shoumikhin as a code owner May 21, 2026 03:09
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 21, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19712

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure

As of commit 4e5b024 with merge base 64684c7 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 21, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 21, 2026

@metascroy has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105904682.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot merged commit 8fbfed9 into pytorch:main May 21, 2026
183 of 188 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants