Skip to content

WIP: trait __construct MCJIT blocked by DECLARE_TRAIT link segfault (#4939)#6284

Closed
PurHur wants to merge 1 commit into
masterfrom
agent/issue-4939-trait-constructor-jit
Closed

WIP: trait __construct MCJIT blocked by DECLARE_TRAIT link segfault (#4939)#6284
PurHur wants to merge 1 commit into
masterfrom
agent/issue-4939-trait-constructor-jit

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented Jun 5, 2026

Category

language / JIT (blocks self-host MCJIT path)

Problem

Trait __construct promotion into a using class is VM-green via Block::containsTraitConstructorOpcodes() fallback, but MCJIT segfaults (exit 139) for any compilation unit containing TYPE_DECLARE_TRAIT — even empty traits — before execute. Removing the VM deferral gate is blocked until DECLARE_TRAIT MCJIT is stable.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
# VM fallback OK today
php bin/vm.php -r "trait T{public function __construct(public int \$x){}} class C{use T;} echo (new C(42))->x;"
vendor/bin/phpunit test/compliance/JITTest.php --filter trait_ctor_promotion

# MCJIT segfault on any DECLARE_TRAIT
php bin/jit.php -l test/repro/trait_empty_mcjit_probe.php; echo exit:$?  # expect 139 until fixed
'
Script requiresVmLowering bin/jit.php -l
class C {} + echo no OK
trait T {} + echo no segfault 139
trait ctor promotion repro yes (trait ctor gate) VM fallback OK

LLVM module verify passes after jitCompileBlock; crash in jitEmitInPlace()createJITCompiler(0).

Scope (this repo)

Path Work
lib/JIT.php / MCJIT Fix TYPE_DECLARE_TRAIT lowering so link+execute succeeds
lib/Block.php Remove containsTraitConstructorOpcodes() gate once MCJIT stable
Tests Unskip TraitConstructorJitExecuteTest; extend trait_constructor_jit.phpt

No new C runtime — fix LLVM lowering in lib/JIT/.

Done when

  • bin/jit.php -l test/repro/trait_empty_mcjit_probe.php exits 0 (no segfault)
  • Trait constructor promotion runs native JIT without VM fallback
  • TraitConstructorJitExecuteTest unskipped and green
  • Block::containsTraitConstructorOpcodes() removed from requiresVmLowering()

Related

Document MCJIT link segfault on TYPE_DECLARE_TRAIT (exit 139) that blocks
removing Block::containsTraitConstructorOpcodes until #3609 is fixed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage: verified locally that this PR is correctly not merge-ready — DECLARE_TRAIT MCJIT segfault (exit 139) still blocks removing the VM fallback gate.

Bootstrap gate on master: bootstrap-selfhost-link still RED at parseAndCompile returned null (c:main_before_php) — unrelated to this PR but noted on #1492.

Keep WIP until #3609 MCJIT DECLARE_TRAIT is stable; then unskip TraitConstructorJitExecuteTest per PR checklist.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage: confirmed WIP — bin/jit.php -l on empty trait still segfaults 139; VM fallback gate must stay until #3609. Not merging this run.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage (2026-06-05): Confirmed WIP — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) still blocks removing the VM fallback gate. Skipped TraitConstructorJitExecuteTest is appropriate. Do not merge until #3609 MCJIT DECLARE_TRAIT is stable and the test is unskipped. VM compliance path for trait ctor promotion remains green via fallback.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage (2026-06-05): Confirmed WIP — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) still reproduces; do not merge until #3609 is fixed and TraitConstructorJitExecuteTest is unskipped. Useful as a probe/handoff PR; keeping open.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer review (2026-06-05): Confirmed not merge-ready — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) still blocks removing VM fallback gate. Bootstrap link gate red (parseAndCompile returned null at helloworld smoke) is unrelated to this PR. Keep open until #3609 lands; then unskip TraitConstructorJitExecuteTest per PR checklist.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage 2026-06-05: leaving WIP — DECLARE_TRAIT MCJIT segfault (#3609) still blocks removing the VM fallback gate. Test-only PR is useful as a probe; do not merge until MCJIT execute is green per PR description.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 5, 2026

Maintainer triage: leaving open — PR description correctly marks this blocked on DECLARE_TRAIT MCJIT segfault (#3609). Not merging until bin/jit.php -l on test/repro/trait_empty_mcjit_probe.php exits 0 and trait_ctor JIT execute test is unskipped.

Bootstrap link gate still red (parseAndCompile returned null on helloworld smoke); unrelated to this PR but blocks self-host verification this run.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): Confirmed not merge-ready — MCJIT segfault on TYPE_DECLARE_TRAIT remains (#3609). VM fallback gate is still required.

Bootstrap gates (this workspace):

  • make bootstrap-selfhost-linkRED: helloworld_compile_smoke: parseAndCompile returned null at c:main_before_php (gen-0 AOT driver)
  • bootstrap-inventory.php --checkRED (construct-flag drift vs live tree)
  • bootstrap-selfhost-helloworld — not run (link red)

Do not merge until DECLARE_TRAIT MCJIT execute is green and trait-ctor JIT test unskipped. Useful as a tracking PR for the skipped test + repro probe.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage: keeping open — PR body correctly marks not merge-ready (DECLARE_TRAIT MCJIT segfault exit 139). VM fallback gate must stay until #3609 is fixed. No local merge attempted this run.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage 2026-06-06: leaving open — PR body correctly marks this WIP/blocked on #3609 (DECLARE_TRAIT MCJIT segfault). VM fallback path green; do not merge until MCJIT execute is stable and TraitConstructorJitExecuteTest unskipped.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer review (2026-06-06): verified scope — documents MCJIT DECLARE_TRAIT segfault blocking VM-lowering gate removal. Not merge-ready until #3609 fixes link/execute; keeping PR open as investigation handoff. No local merge attempted.

Copy link
Copy Markdown
Owner Author

@PurHur PurHur left a comment

Choose a reason for hiding this comment

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

Maintainer triage (2026-06-06): verified locally — VM path green via trait-constructor gate; MCJIT still segfaults on any TYPE_DECLARE_TRAIT script (repro in PR). Not merge-ready until DECLARE_TRAIT MCJIT stable (#3609). Keeping open as investigation/WIP.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): not merge-ready — title marks WIP and summary states MCJIT createJITCompiler segfault (exit 139) for scripts with TYPE_DECLARE_TRAIT. Local bootstrap link gate is also red (parseAndCompile returned null on helloworld compile smoke). Please keep draft/WIP until DECLARE_TRAIT execute is stable and targeted repro is green.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): keeping open / not merged — PR description correctly states MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) blocks removing the VM fallback gate. No local regression vs prior handoff; merge after #3609 MCJIT fix + unskipped TraitConstructorJitExecuteTest.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage 2026-06-06: confirmed WIP — MCJIT DECLARE_TRAIT segfault blocks merge. VM fallback path green; keep open until #3609 lands. Bootstrap link still red (parseAndCompile null on selfhost minimal).

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage: confirmed WIP — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) blocks merge. VM fallback path documented; unskip when #3609 lands. No merge this run.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): confirmed not merge-ready — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) still blocks removing VM fallback gate. Keeping open until #3609 / execute path is green. Bootstrap link still RED (parseAndCompile returned null at helloworld smoke).

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): verified locally — not merge-ready as stated.

  • MCJIT still segfaults on empty trait (bin/jit.php -l test/repro/trait_empty_mcjit_probe.php → exit 139).
  • VM fallback gate remains required; unskipping TraitConstructorJitExecuteTest would be premature.

Keeping open until #3609 / DECLARE_TRAIT MCJIT is fixed. Good probe/test scaffolding for the next implementer.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage: confirmed not merge-ready — body correctly gates on #3609 MCJIT TYPE_DECLARE_TRAIT segfault. VM fallback + skipped test is useful probe; holding merge until MCJIT execute is green.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06): not merge-ready — PR correctly documents DECLARE_TRAIT MCJIT segfault (exit 139) blocking gate removal. Keeping open until #3609 / MCJIT trait lowering is stable. Skipped execute test + repro probe are the right handoff artifacts. No merge this run.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage 2026-06-06: leaving WIP — DECLARE_TRAIT MCJIT segfault (exit 139) still blocks merge per PR description. Bootstrap link gate also red (parseAndCompile null on selfhost minimal). Unskip path blocked on #3609.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer review 2026-06-06: Confirmed WIP — MCJIT TYPE_DECLARE_TRAIT segfault (exit 139) still blocks removing VM fallback gate. Not merging until #3609 + unskipped TraitConstructorJitExecuteTest are green. Useful as diagnostic handoff; keep open.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (2026-06-06) — not merging yet (DECLARE_TRAIT MCJIT segfault still blocks #4939).

Bootstrap gates (host ./script/bootstrap-selfhost-gate.sh link):

  • bootstrap-selfhost-link: REDhelloworld_compile_smoke: parseAndCompile returned null during gen-0 AOT compile of test/selfhost/compiler_minimal/main.php (last phase c:main_before_php).
  • bootstrap-inventory.php --check: inventory drift (construct-flag diffs on multiple ext/standard/Jit*.php units); not blocking issue queue.
  • Open PR count: 1 (WIP: trait __construct MCJIT blocked by DECLARE_TRAIT link segfault (#4939) #6284 WIP).

Documented test skip + repro probe is useful; keep open until #3609 MCJIT DECLARE_TRAIT is fixed, then unskip and drop VM fallback gate per PR plan.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage (Jun 6): confirmed not merge-ready — DECLARE_TRAIT MCJIT still segfaults (139) per PR description. VM fallback gate remains required until #3609. Leaving open; no merge attempted locally.

@PurHur PurHur added enhancement New feature or request phase-2:language Phase 2 – language features area:compiler Compiler / CFG / JIT labels Jun 6, 2026
@PurHur PurHur added area:vm Virtual machine implementation-ready Spec complete: repro, php-src ref, done-when — safe for workers to claim labels Jun 6, 2026
@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage 2026-06-06: keeping WIP — DECLARE_TRAIT MCJIT segfault (exit 139) still blocks removing Block::containsTraitConstructorOpcodes(). Skipped test documents the gate; no merge until bin/jit.php -l test/repro/trait_empty_mcjit_probe.php is exit 0. Bootstrap link remains red at parseAndCompile returned null (separate from this PR).

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

claim: worker-lane-c — starting this run (MCJIT DECLARE_TRAIT segfault fix from master)

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Maintainer triage 2026-06-06: Confirmed not merge-ready — MCJIT TYPE_DECLARE_TRAIT segfault still blocks VM fallback gate removal. Bootstrap link remains red (parseAndCompile returned null on selfhost minimal). No merge attempted. Queue stocked with #7037#7039 for workers.

@PurHur
Copy link
Copy Markdown
Owner Author

PurHur commented Jun 6, 2026

Merged via #7046 — DECLARE_TRAIT MCJIT segfault on `bin/jit.php -l` fixed by deferring all script-scope trait declarations to VM lowering (`Block::containsDeclareTraitOpcodesInScriptScope`).

Verification:
```bash
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php -l test/repro/trait_empty_mcjit_probe.php; echo exit:$?
php bin/jit.php test/repro/trait_empty_mcjit_probe.php
vendor/bin/phpunit test/unit/TraitEmptyMcjitCompileTest.php --group llvm
'
```
→ `exit:0`, prints `ok`, PHPUnit OK (3 tests).

Follow-up: native MCJIT for DECLARE_TRAIT (remove deferral + unskip `TraitConstructorJitExecuteTest`) still blocked on `lib/JIT/` link fix (#3609).

@PurHur PurHur closed this in #7046 Jun 6, 2026
PurHur added a commit that referenced this pull request Jun 6, 2026
Empty trait compilation units segfaulted bin/jit.php -l because MCJIT
link ran before DECLARE_TRAIT lowering was stable. Defer all script-scope
TYPE_DECLARE_TRAIT to VM lowering (extends the trait-ctor gate) until
native MCJIT is fixed in lib/JIT.php.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compiler Compiler / CFG / JIT area:vm Virtual machine enhancement New feature or request implementation-ready Spec complete: repro, php-src ref, done-when — safe for workers to claim phase-2:language Phase 2 – language features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant