Fix UB in to_string(Error) for unrecognized error codes (#18554)#18554
Fix UB in to_string(Error) for unrecognized error codes (#18554)#18554alexey-sidnev wants to merge 2 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18554
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 Cancelled JobsAs of commit c70cfd1 with merge base 3d63ad8 ( CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@alexey-sidnev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D97662639. |
This PR needs a
|
Summary: executorch::runtime::to_string(Error) returns const char* via a switch statement with no default case. For unrecognized error codes, the function falls off the end without returning (undefined behavior), which in practice returns nullptr. The fix: 1. Adds a fallback return "Error::Unknown" after the switch in to_string() (without a default: case, preserving -Wswitch coverage for missing enum values). 2. Adds tests for to_string() covering all 21 enum values and the unknown error code path. Differential Revision: D97662639
fd5b53a to
baffc13
Compare
Summary: Pull Request resolved: pytorch#18554 executorch::runtime::to_string(Error) returns const char* via a switch statement with no default case. For unrecognized error codes, the function falls off the end without returning (undefined behavior), which in practice returns nullptr. The fix: 1. Adds a fallback return "Error::Unknown" after the switch in to_string() (without a default: case, preserving -Wswitch coverage for missing enum values). 2. Adds tests for to_string() covering all 21 enum values and the unknown error code path. Differential Revision: D97662639
baffc13 to
eebaa51
Compare
Summary: executorch::runtime::to_string(Error) returns const char* via a switch statement with no default case. For unrecognized error codes, the function falls off the end without returning (undefined behavior), which in practice returns nullptr. The fix: 1. Adds a fallback return "Error::Unknown" after the switch in to_string() (without a default: case, preserving -Wswitch coverage for missing enum values). 2. Adds tests for to_string() covering all 21 enum values and the unknown error code path. Differential Revision: D97662639
eebaa51 to
7d87728
Compare
Summary: Pull Request resolved: pytorch#18554 executorch::runtime::to_string(Error) returns const char* via a switch statement with no default case. For unrecognized error codes, the function falls off the end without returning (undefined behavior), which in practice returns nullptr. The fix: 1. Adds a fallback return "Error::Unknown" after the switch in to_string() (without a default: case, preserving -Wswitch coverage for missing enum values). 2. Adds tests for to_string() covering all 21 enum values and the unknown error code path. Differential Revision: D97662639
7d87728 to
9c41977
Compare
|
@alexey-sidnev has imported this pull request. If you are a Meta employee, you can view this in D97662639. |
|
@pytorchbot merge |
|
Mergebot is not configured for this repository. Please use the merge button provided by GitHub. |
Summary:
executorch::runtime::to_string(Error) returns const char* via a switch statement with no default case. For unrecognized error codes, the function falls off the end without returning (undefined behavior), which in practice returns nullptr.
The fix:
Differential Revision: D97662639