JIT: Fix null-check ordering in EH regions - #133827
Conversation
Ensure this pointer null checks happen before inlinee side effects observable by catch handlers and exception filters. Prevent early propagation from folding these checks across such side effects, and add regression coverage for both cases. Fixes dotnet#133714 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@EgorBo PTAL No diffs expected |
There was a problem hiding this comment.
🟡 Changes recommended
Nested inlining can still miss the enclosing protected-region state, leaving the null-check ordering bug unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
JIT: Fix null-check ordering in EH regions
This PR preserves receiver null-check ordering across inlinee side effects observable by exception handlers and filters.
Changes:
- Treat assignments as visible side effects in protected regions.
- Prevent unsafe null-check folding.
- Add catch and filter regression coverage.
File summaries
| File | Summary |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_133714.cs |
Adds regression coverage. |
src/coreclr/jit/importer.cpp |
Preserves null checks across inlinee assignments. |
src/coreclr/jit/earlyprop.cpp |
Restricts null-check folding in EH regions. |
src/coreclr/jit/compiler.h |
Updates the helper parameter name. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
|
There were a couple of minor diffs, looks like just one method. |
Use HasPotentialEHSuccs to identify try and filter regions when preserving null-check ordering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fb0bcff-10ee-4de2-a4dd-442ad89b2b11
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
The new test is failing on mono and coreclr Wasm. Going to exclude mono and see if #133932 fixes things for Wasm. |
The exception-filter scenario targets CoreCLR JIT behavior and fails on Mono. Keep the catch scenario cross-runtime while restricting only the filter regression to non-Mono runtimes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fb0bcff-10ee-4de2-a4dd-442ad89b2b11
Yes, that fixes the Wasm failure. So will wait on that PR. |
There was a problem hiding this comment.
🔵 Needs a closer look
A moderate unresolved concern remains about broad assignment visibility in EH regions.
Review details
Suppressed comments (1)
src/coreclr/jit/importer.cpp:14846
- This broadens the side-effect test from
GTF_GLOBALLY_VISIBLE_SIDE_EFFECTSto everyGTF_ASGwhenever the call site has EH successors. That makes assignments to inlinee-private temporaries EH-visible too, so an inlined method that initializes an unobservable local before its firstthisdereference will retain a separate null check inside every protected region, even though no handler can observe that local. Please restrict this to stores that can actually reach an EH successor (rather than treating all assignments as visible) to avoid a broad null-check-elimination regression.
return GTF_GLOBALLY_VISIBLE_SIDE_EFFECTS(flags) || (localStoresAreVisible && ((flags & GTF_ASG) != 0));
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
@jakobbotsch will need re-approval, the new test causes mono failures and a (since fixed) Wasm failure. |
Ensure this pointer null checks happen before inlinee side effects observable by catch handlers and exception filters. Prevent early propagation from folding these checks across such side effects, and add regression coverage for both cases. Fixes dotnet#133714 > [!NOTE] > This pull request description was generated by GitHub Copilot. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3fb0bcff-10ee-4de2-a4dd-442ad89b2b11
Ensure this pointer null checks happen before inlinee side effects observable
by catch handlers and exception filters. Prevent early propagation from folding
these checks across such side effects, and add regression coverage for both
cases.
Fixes #133714
Note
This pull request description was generated by GitHub Copilot.