Skip to content

Fix the bug backlog: coercion, references, crashes, uninitialised typed properties, access checks, async (ABI 24) - #429

Merged
blacktrs merged 50 commits into
mainfrom
integ/issue-sweep
Oct 24, 2026
Merged

blacktrs merged 50 commits into
mainfrom
integ/issue-sweep

Conversation

@blacktrs

Copy link
Copy Markdown
Contributor

Summary

A sweep over the open bug backlog: issues grouped by shared root cause, each fixed at the root, with its repro promoted to a regression case. ABI goes 22 -> 24 (denormal float encoding, init bitmap for typed properties); no bootstrap pin raise is needed.

Changes by group

Scalar coercion — a numeric string reaching an int parameter, return or typed property is converted (#402); "10" + "5.5" is float(15.5) and "9" ** 2 is int(81) (#403); a statically-null local used as an array key is "" (#412).

Crashes — $cb(...$args) through a builtin name (#411); automatic cycle collector SIGBUS when an object is the first allocation of a malloc region (#413); denormal floats in a cell no longer look like pointers (#331, ABI 23).

References — unset or rebind of a by-ref name (#346, #347, #200); a stored &$v of a by-ref param is shared instead of copied (#344, #349, #351); $o->p = &$v binds the property (#345, #58); references stored through inherited constructors and first-class callables (#352); nested element reference pinned by a case (#251).

Runtime and stdlib — array_map with several arrays (#405), is_resource after fclose (#406), __FUNCTION__ at top level (#408), get_defined_vars() (#264), Ffi\Ptr in user code and a C NULL return (#400, #401), call_user_func_array into a variadic closure (#414), destructor timing for use (&$x) (#69).

Garbage values — omitted mixed &$v = null (#415), the value of $o[$k] = <string> as an expression (#420, #397), a denied property read falling back to __get (#419).

Language checks — nullable typed class constants parse (#418); a trait method weakening the parent's visibility is rejected (#421); private access from an unbound closure is rejected (#422).

Uninitialised typed properties — reading one throws, as in php (#417); json_encode, get_object_vars, serialize, var_dump skip or flag them (#115). Costs one hidden bitmap word only in classes that need it; a constructor analysis removes the check where every path assigns.

Async — awaitAny escalates a late loser's failure (#423), Semaphore::release() throws on an over-release (#424), the poll backend honours $maxEvents (#426).

serialize / perf — unserialize rejects malformed input like php (#282); faster object unserialize (3x) and array_splice / array_combine (#280, #278, #285 stay open: object serialize ~2.8x php, shared hash-insert path).

Not fixed here

#353 (partly), #34, #61, #187, #350, #395, #59 need design; #409 left as is on purpose.

Verification

  • Full AOT suite on macOS arm64: 2454 passed, 0 failed, 2 skipped.
  • symfony-console: 9/9 invocations match Zend (json and xml included).
  • symfony-app: builds, prod and cold dev boot serve 200 and 404.
  • Not run: difftest, the Linux gate, the self-host fixpoint gate. The ABI bump and the new typed-property read check make the Linux gate the important one.

Fixes #115, fixes #200, fixes #251, fixes #264, fixes #282, fixes #331, fixes #344, fixes #345, fixes #346, fixes #347, fixes #349, fixes #351, fixes #352, fixes #397, fixes #400, fixes #401, fixes #402, fixes #403, fixes #405, fixes #406, fixes #408, fixes #411, fixes #412, fixes #413, fixes #414, fixes #415, fixes #417, fixes #418, fixes #419, fixes #420, fixes #421, fixes #422, fixes #423, fixes #424, fixes #426, fixes #58, fixes #69

…string at call, return and property-store sinks

Fixes #402
…), offset(), address

A Ptr is its address at run time and no class is linked, so the members
lower to int_to_ptr / ptr_to_int and a C NULL return answers isNull().

Fixes #400
Fixes #401
… ctors, first-class callables and dynamic method calls

Inherited constructors resolve up the parent chain, a pending $o->m(...) shim asks every holder of the method name, and a dynamic call no longer hoists a property argument into a copy. Spread and DynProp arguments stay open (#61, #353).

Fixes #352
A typed by-ref param whose reference is stored rides a cell and is moved into a frame box on entry, so every &$v shares it and the caller sees later writes.

Fixes #344
The property slot is rebound to a REF cell (retain the box, drop what the slot held),
reads already deref promoted slots. Typed-property targets keep the value copy until
a typed-slot reference representation exists.

Fixes #345
Fixes #58
…e a pointer (ABI v23)

A denormal double with bits in (0xFFFF, 2^48) passed the plausible-pointer
window and was dereferenced by the ptr-8 probes (is_resource, instanceof,
is_array...). Lossless fix, not a flush to 0.0: box_float / box_by_repr or
FLOAT_DENORM_TAG (0x7FF0<<48, an sNaN header box_float otherwise never emits)
into those words; every cell->double read (tagged_to_double and the asfloat
arms, array float-element decode, json/serialize writers) masks it back.
Chosen over a new DENORM cell tag: the word stays in the synthetic FLOAT
class, so no tag dispatch changes.

Fixes #331
# Conflicts:
#	src/Compile/Mir/Passes/EmitLlvmObjects.php
# Conflicts:
#	prelude/array_fns.php
#	prelude/resource.php
#	src/Compile/Mir/Passes/EmitLlvmObjects.php
#	src/Compile/Mir/Passes/LowerFromAst.php
#	tests/aot/cases/array_map_zip.php
#	tests/aot/expected/array_map_zip.out
…as an expression

An ArrayAccess offsetSet has no result of its own; park a non-trivial value in a local and read it back.

Fixes #420
… uninitialized (ABI v24)

A class tree declaring a typed property with no default (not promoted, not
hooked) gets an init bitmap at one tree-wide offset past every member's
properties and bag; allocation zeroes it, clone copies it. No reader or
writer consults it yet.
Every write path into a property php may start uninitialized marks it in the
init bitmap: the typed and erased stores, the class-id writers, union and
rebind stores, array write-back into a property, by-reference addresses and
clone-with. Nothing reads the bit yet.
…ide any class

A closure lowered outside a class has global scope unless the program rebinds closures (bindTo, call, Closure::bind), in which case the check stays off.

Fixes #422
A plain read of a property php starts uninitialized tests its init bit and
throws Error "Typed property C::$p must not be accessed before initialization".
Write bases (element writes, references, by-ref arguments, isset/unset/??)
are not reads and keep vivifying.

Fixes #417
…n follow php

isset() and ?? answer false/the default, unset() makes a typed property
uninitialized again, json_encode / get_object_vars / (array) / print_r /
var_export / serialize leave it out, var_dump prints uninitialized(T) and
counts only written properties, ReflectionProperty::isInitialized() asks
the bitmap. isset() of a written raw int/float/bool property is true even
when it holds 0.

Fixes #115
A conservative definite-assignment scan of the constructor's leading
straight-line run ($this->p = expr, local assignments, parent::__construct)
before anything could observe the object drops those properties from the
maybe-uninitialized set, so most classes carry no bitmap and pay no check.
A property a subclass's constructor may leave unwritten stays checked on
every ancestor that declares it.
…ip slot bookkeeping without R:

Refs #280: objects unserialize 325 -> 110 ms (php 50) on 20k objects
…ombine: one copy fewer, ValueError on count mismatch (assoc splice 735->506 us, combine 520->453 us at 10k; Refs #285, #278)
…id for php, and a borrowed element read keeps the plain store as an assignment value
@blacktrs
blacktrs merged commit a15ad0f into main Oct 24, 2026
38 of 42 checks passed
@blacktrs
blacktrs deleted the integ/issue-sweep branch October 24, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment