Ruby: More captured exit read nodes#19483
Merged
yoff merged 4 commits intogithub:mainfrom May 14, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends the liveness analysis for captured variables to include exceptional exits and adds tests to verify this behavior.
- Remove the
bb.isNormal()guard in thecapturedExitReadpredicate to cover exception-driven exits - Add
do_twice/retry_oncehelpers and corresponding tests (get_done_twice,get_retried) - Document the new exceptional-exit semantics in a change note
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ruby/ql/test/query-tests/variables/DeadStoreOfLocal/DeadStoreOfLocal.rb | Added do_twice and retry_once helpers and tests to ensure blocks run twice or on retry |
| ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll | Removed the bb.isNormal() guard in capturedExitRead to include exception exits |
| ruby/ql/lib/change-notes/2025-05-13-captured-variables-live-more-often.md | Added a note on captured variables remaining live on exceptional exit |
Comments suppressed due to low confidence (1)
ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll:106
- Update the doc comment above this predicate to mention that captured variables are also considered live on exceptional exits (not just normal exits).
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
ruby/ql/test/query-tests/variables/DeadStoreOfLocal/DeadStoreOfLocal.rb
Outdated
Show resolved
Hide resolved
ruby/ql/lib/change-notes/2025-05-13-captured-variables-live-more-often.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Some stage timings increase, but overall everything is slightly faster. And we remove several false positives :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.