FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Python: fix shared CFG exception-handler reachability by yoff · Pull Request #22380 · github/codeql · GitHub

/ codeql Public

Python: fix shared CFG exception-handler reachability - #22380

Open
yoff wants to merge 3 commits into
github:mainfrom
yoff:yoff-fix-shared-cfg-ssa-regressions
Open

Python: fix shared CFG exception-handler reachability#22380
yoff wants to merge 3 commits into
github:mainfrom
yoff:yoff-fix-shared-cfg-ssa-regressions

Conversation

yoff commented Aug 19, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

Fixes exception-handler reachability in the shared Python CFG introduced by #21921 and now present on main. Testing the dataflow switch-over in #21925 surfaced the bug.

Leaf expressions that may throw, including bare yield and plain imports, were not always connected to typed exception-handler entries. The fix uses the canonical shared-CFG injects mapping when starting exceptional completion, so these expressions reach the appropriate catch entry.

Tests

Adds focused inline coverage for:

  • bare yield reaching a GeneratorExit handler;
  • a plain import reaching an ImportError handler.

DCA impact

The switch-over DCA in #38556 exposed effects of the missing exception edges in mypy, CPython, and youtube-dl. Restoring these edges recovers the affected catch reachability and downstream flow.

Validation

  • codeql test run python/ql/test/library-tests/ControlFlow/shared-cfg-exceptions
  • codeql query format --check-only python/ql/test/library-tests/ControlFlow/shared-cfg-exceptions/ExceptionReachabilityTest.ql

Copilot AI balanced review requested due to automatic review settings August 19, 2026 11:10
yoff requested a review from a team as a code owner August 19, 2026 11:10
yoff added the no-change-note-required This PR does not need a change note label Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Fixes shared Python CFG/SSA regressions affecting exception-handler reachability and module-export phi uses.

Changes:

  • Routes exceptional completion through canonical CFG nodes.
  • Preserves synthetic normal-exit uses for generic SSA definitions.
  • Adds regression tests for both fixes.
Show a summary per file
File Description
python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll Uses canonical CFG-node mapping for exception flow.
python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll Supports phi definitions when resolving uses.
python/ql/test/library-tests/ControlFlow/shared-cfg-exceptions/test.py Adds yield and import exception cases.
python/ql/test/library-tests/ControlFlow/shared-cfg-exceptions/ExceptionReachabilityTest.ql Checks typed-handler reachability.
python/ql/test/library-tests/ControlFlow/shared-cfg-exceptions/ExceptionReachabilityTest.expected Records expected exception results.
python/ql/test/library-tests/dataflow-new-ssa/test.py Adds conditional module-export coverage.
python/ql/test/library-tests/dataflow-new-ssa/SsaTest.ql Checks synthetic exit uses for phi definitions.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/7 changed files
  • Comments generated: 0
  • Review effort level: Balanced

yoff added the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Aug 19, 2026
yoff force-pushed the yoff-fix-shared-cfg-ssa-regressions branch from 9055769 to 94aa7e2 Compare August 19, 2026 11:24
yoff force-pushed the yoff/python-shared-cfg-dataflow-flip branch from 0394945 to c69ba9a Compare August 19, 2026 15:39
yoff force-pushed the yoff-fix-shared-cfg-ssa-regressions branch from 94aa7e2 to a93d631 Compare August 19, 2026 15:42
yoff changed the title Python: fix shared CFG and SSA correctness regressions Python: fix shared CFG exception-handler reachability Aug 19, 2026
yoff and others added 2 commits August 20, 2026 08:54
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
yoff force-pushed the yoff-fix-shared-cfg-ssa-regressions branch from a93d631 to 3dfc77e Compare August 20, 2026 06:55
yoff requested review from a team as code owners August 20, 2026 06:55
yoff changed the base branch from yoff/python-shared-cfg-dataflow-flip to main August 20, 2026 06:56
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 860cd56d-31cf-49f4-a947-45e0d72447c6

aschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

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

Labels

Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish no-change-note-required This PR does not need a change note Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL