Skip to content

contrib.host.python: restore nested map context - #3458

Closed
adilalperenciftci wants to merge 1 commit into
aether-lang-dev:mainfrom
adilalperenciftci:fix/python-host-map-context
Closed

adilalperenciftci wants to merge 1 commit into
aether-lang-dev:mainfrom
adilalperenciftci:fix/python-host-map-context

Conversation

@adilalperenciftci

Copy link
Copy Markdown
Contributor

Summary

I reproduced a nested python.run_sandboxed_with_map call replacing the outer shared-map token. The inner return reset the token to zero, so the outer Python frame could no longer read or write its own map. The depth-limit return also occurred after activating the new token.

  • Reject an over-depth call before changing the active map context.
  • Save and restore the caller's token around each hosted run.
  • Keep the outermost return fail-closed with no active token.
  • Add a real embedded-CPython regression covering the inner map, restored outer map, and final cleanup.

This is independent of the checker-stack work in #3334; its current head leaves the shared-map token lifecycle unchanged.

Verification

  • BEFORE: run=0 inner=ok outer=(null) cleared=0
  • AFTER: run=0 inner=ok outer=outer cleared=0
  • make contrib MODULES=python: 1 built, 0 skipped
  • make contrib-host-check: Python 5 passing; 0 host-check failures
  • make check-changelog
  • make check-tests
  • make check-docs
  • make test: 634 passed, 0 failed

Signed-off-by: Adil Alperen Çiftci adilalperenciftci@users.noreply.github.com

Copilot AI balanced review requested due to automatic review settings October 29, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Preserve the previous shared-map token around nested run_sandboxed_with_map calls and restore it when the inner call returns. Reject an over-depth entry before activating or freezing the new map context.

Add an embedded CPython regression covering the inner map, restored outer map, and final token cleanup.

Signed-off-by: Adil Alperen Ciftci <adilalperenciftci@users.noreply.github.com>
@paul-hammant

Copy link
Copy Markdown
Collaborator

Thanks @adilalperenciftci! This landed in #3474, which batched nine of your PRs and merged on 2026-10-30 (ca1dae7d). Your commit went in unchanged with your authorship, so this PR is superseded, and I'm closing it.

On top of your commit, #3474 makes host_python_map_context FAIL (rather than SKIP) when python3-config is found but the build fails, passes -lrt only on Linux, and honours $CC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants