◐ Shell
clean mode source ↗

bpo-29347: Fix possibly dereferencing undefined pointers when creating weakref objects by zhangyangyu · Pull Request #188 · python/cpython

@zhangyangyu

akruis added a commit to akruis/cpython that referenced this pull request

Dec 31, 2018
…nd coroutines

Improve the finalisation of a soft switched YIELD_FROM instruction.

akruis added a commit to akruis/cpython that referenced this pull request

Dec 31, 2018
…ed methods

Enable stackless calls of the following methods:
- generator.send() (generator.__next__() was already stackless);
- coroutine.send();
- coroutine_wrapper.__next__() and coroutine_wrapper.send();
- async_generator_asend.__next__() and async_generator_asend.send().

This change needs more tests.

akruis added a commit to akruis/cpython that referenced this pull request

Jan 1, 2019
Fix a error handling in the YIELD_FROM finalisation code.
Add tests and changelog.txt

akruis pushed a commit to akruis/cpython that referenced this pull request

Jan 12, 2019
…(async) generators and coroutines

Enable soft switching for iterators/coroutines called by "yield from".
Improve the finalisation of a soft switched YIELD_FROM instruction.
Enable stackless calls of the following methods:
- generator.send() (generator.__next__() was already stackless);
- coroutine.send();
- coroutine_wrapper.__next__() and coroutine_wrapper.send();
- async_generator_asend.__next__() and async_generator_asend.send().

akruis added a commit to akruis/cpython that referenced this pull request

Apr 20, 2021
…#188

This commit fixes an assert statement, that could fail since python#188.
No functional change.

(cherry picked from commit 5595eec)

akruis added a commit to akruis/cpython that referenced this pull request

May 27, 2021
…#188

This commit fixes an assert statement, that could fail since python#188.
No functional change.

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 27, 2026
…4.A.5 probe

Closes two spec gaps surfaced by pythia python#188 2026-04-27:

(a) §6 python#5 'PhxHirBuilderState 100% of state' acceptance criterion was
not mechanically testable — '100%' undefined, no falsifier. Now adds
explicit grep-rule against builder.cpp filtering out accepted access
patterns (state_.<field>, _cpp/_c bridge defs/calls, comments). Any
other hit = unmigrated C++ direct member access = fail acceptance.

(b) §4.A.5 inserted as a class-state extraction PROBE between Phase
4.A and 4.B. ~30-50 LOC, 1 commit. Pilot-5 dry-run on the simplest
Class A field (kwnames_) to surface silent-drift / mutator-enumeration /
JIT_DCHECK-equality risks BEFORE Phase 4.C burns its 33-53 commits on
the harder containers. §5.A close gate is LOC-trajectory only and
won't catch class-state failure modes; §4.A.5 fills that gap.

Authored 2026-04-27 per pythia python#188 + supervisor 2026-04-27T09:36:01Z.
'A rehearsal in an empty theater predicts only that the lights work.'

SonicField added a commit to SonicField/cpython that referenced this pull request

Apr 27, 2026
Pythia python#188 class-state-extraction PROBE (supervisor 2026-04-27T09:36:01Z
authored §4.A.5; supervisor 09:45:06Z accepted in-session execution;
theologian patch-shape APPROVE 09:49:24Z). Pilot-5 dry-run on the
simplest Class A field — kwnames_, the most-recent KW_NAMES Register*
slot — to surface class-state extraction failure modes (silent drift,
mutator-site enumeration miss, JIT_DCHECK equality drift) BEFORE
Phase 4.C burns 33-53 commits on harder containers.

Migration is single-commit + same-instant deletion:

  Python/jit/hir/builder.h
    Delete the C++ field 'Register* kwnames_{nullptr};'. Update the
    Class A mirror comment (line 693-697) to reflect kwnames_ removal
    + document the §4.A.5 probe entry.

  Python/jit/hir/builder.cpp
    builder.cpp:2538 — sole C++ direct read site rewritten to
    state_.kwnames == nullptr (post-translate KW_NAMES-stash invariant).
    builder.cpp:2928-2935 — extern "C" hir_builder_get/set_kwnames
    bridge bodies redirected to state_.kwnames; the static_cast<void*>
    / static_cast<Register*> drop because state_.kwnames is already
    void* — no implicit conversion.

Mutator-site enumeration: ALL writes go through hir_builder_set_kwnames
(2 callers in builder_emit_c.c:968 + 3878); ALL reads go through
hir_builder_get_kwnames (3 callers in builder_emit_c.c:962 + 3857) +
the 1 direct-read C++ site at builder.cpp:2538. Zero C++ direct write
sites outside the bridge body — audited.

JIT_DCHECK equality (spec §4.A.5 step 3) is moot in the single-commit
migration: the C++ field is deleted in the same commit that redirects
the bridges, so no parallel state can drift. Theologian 09:49:24Z noted
the spec wording was overconservative for the single-commit case.

Falsifier (§6 python#5 grep-rule) result post-migration:
  grep -nE '\\bkwnames_\\b' Python/jit/hir/builder.cpp
  → ZERO HITS. Field name is no longer anywhere in the codebase.

Build + ABBA: scripts/build_phoenix.sh --clean PASS (testkeeper
09:55:03Z). 4-bench ABBA GEO-MEAN 1.28x (matches BLME batch 2 baseline);
gen_simple 0.75x is pre-existing (BLME batch 2 0.74x; push-59 baseline
0.70x; same-session stable, structural causal absence — kwnames_
touches KW-arg dispatch not generator FRAME ops). No >5% drop trigger;
well above 1.0x floor.

Acceptance per spec §4.A.5: ABBA clean + zero functional regressions =
probe PASS = Class A delete approach VALIDATED for Pilot 5 across the
remaining Class A fields (code_ 46 sites, current_func_ ~30,
preloader_ 28, func_, static_method_stack_).