Skip to content

Stdlib: trigger_error() enum error_level TypeError (#9086) - #18272

Merged
PurHur merged 9 commits into
masterfrom
agent/issue-9086-trigger-error-enum-level
Jul 12, 2026
Merged

PurHur merged 9 commits into
masterfrom
agent/issue-9086-trigger-error-enum-level

Conversation

@PurHur

@PurHur PurHur commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix trigger_error() second-argument parsing so enum case operands raise TypeError with Zend-aligned message (… must be of type int, E given) instead of LogicException.
  • VM path uses VmMath::parseIntBuiltinArgForFrame() (same guards as error_reporting() / user_error()).
  • JIT path uses JitIntdiv::lowerIntBuiltinArgForCaller() for runtime enum rejection.

Closes #9086

php-src reference

  • ext/standard/basic_functions.c — PHP_FUNCTION(trigger_error) / user_error

PHP implementation

  • ext/standard/trigger_error_.php

Verification

php bin/vm.php test/repro/maintainer_gap_trigger_error_enum_error_level.php
# trigger_error(): Argument #2 ($error_level) must be of type int, E given

php bin/jit.php test/repro/maintainer_gap_trigger_error_enum_error_level.php
# trigger_error(): Argument #2 ($error_level) must be of type int, E given

php bin/vm.php test/compliance/cases/stdlib/trigger_error_enum_error_level.phpt
php bin/jit.php test/compliance/cases/stdlib/trigger_error_enum_error_level_jit.phpt

make bootstrap-selfhost-vm-driver-execute-probe
# bootstrap-selfhost-vm-driver-execute-probe: OK

Made with Cursor

PurHur and others added 9 commits July 12, 2026 07:54
… IR (#16075)

Defer user-script Context init when the source uses preg_* so nested preg helper
JIT links on a full-init module (~5s) instead of OOM/hanging under minimal user
bodies. Coerce PregJitHelper capture HashTable returns for LLVM verify, route
isset/?? boxed array offsets through HashTableHelper::readHashtableFromValueBox,
and replace full-init superglobal refresh with the user-script native emitter
after the defer path restores PHP_COMPILER_AOT_USER_SCRIPT.

Remaining: standalone binary still segfaults at c:main_before_php on preg execute;
phpc build can still hang with CACHE=0 on large link. Repro: php test/repro/preg_match_aot_minimal.php

Co-authored-by: Cursor <cursoragent@cursor.com>
#16075)

Clear VmActiveContextInitLlvm pending/scheduled statics when deferring user-script
init for preg prelink so thin __init__ emission is not skipped across Context
resets. Add maintainer repro scripts for minimal preg_match and capture/coalesce
AOT paths.

Execute still segfaults after c:main_before_php — runtime init/helper mismatch
remains open on #16075 / PR #18176.

Co-authored-by: Cursor <cursoragent@cursor.com>
After temporary full-init Context creation for preg nested JIT, restore
ensureMinimalUserStandaloneBodies once PHP_COMPILER_AOT_USER_SCRIPT is
re-enabled so compileToFile sees thin standalone stubs.

Execute still segfaults at c:main_before_php when internal_43 calls
__compiler_preg_match → PregJitHelper::matchArgv (IR verified); next
step is runtime init vs nested-helper ABI mismatch after defer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align PregMatchRuntime nested JIT with JitVmHelperLink — ensure
VmActiveContextJitHelper::resolve lowering before compiling PregJitHelper.
Execute segfault in vmpregnative.pregmatch remains open on PR #18176.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Fix array_splice.php JitIntdiv import (same-namespace JitIntdiv)
- CloneWithJitHelper: avoid array_splice in nested clone-with path
- VmPregEngine: foreach max-key scan + manual reverse (skip array_keys/reverse builtins)
- PregMatchRuntime: clarify VmPregNative-only nested compile intent

Root cause for execute segfault: VmPregPure::pregMatch lowers to ExternalMethod
null stub when VmPregNative is nested-compiled without VmPregPure IR. Full
VmPregEngine nested compile still blocked (BoundVariable). Next: register real
vmpregpure::pregmatch proxy or complete VmPregEngine JIT lowering.

Co-authored-by: Cursor <cursoragent@cursor.com>
#16075)

Replace VmPregEngine compile/match throws with abortCompile/limitErrorCode
flags so nested JIT can lower the engine without try/catch. Add VmPregUtf8
(UTF-8 subset without VM frame deps) for VmPregPure. Partial BoundVariable
SCOPE_OBJECT → $this in JIT Context.

Execute still segfaults: nested file compile lacks $this for instance methods;
VmPregPure remains ExternalMethod stub until engine bundle compiles.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move modifier checks into helper methods so nested JIT no longer lowers
match-on-string-offset after an e-modifier guard (structGep crash). Compile
and link for tier-2 preg_capture now succeed; execute still needs VmPregPure
nested lowering or real vmpregpure proxies.

Co-authored-by: Cursor <cursoragent@cursor.com>
…mpile (#18176)

- Resolve BoundVariable before generic `this` name check in JIT Context
- Handle SCOPE_OBJECT and by-ref BoundVariable operands in nested compile
- Seed implicitThisArgument from LLVM param 0 when argVars omitted on-demand
- Broaden instanceMethodUsesThis for file-scope nested class methods (#16075)
- Fix VmPregEngine match/default arms: use $this->abortCompile() not broken $engine closure

Execute still segfaults: VmPregPure remains external stub until VmPregEngine nested JIT completes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Route VM/JIT error_level parsing through VmMath/JitIntdiv guards so enum
case operands raise Zend-aligned TypeError instead of LogicException.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 6a2b99c into master Jul 12, 2026
@PurHur
PurHur deleted the agent/issue-9086-trigger-error-enum-level branch July 12, 2026 14:39
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.

Stdlib: error_reporting()/trigger_error() — enum case operands must TypeError (ext/standard/basic_functions.c)

1 participant