Skip to content

Automatic cycle collection crashes intermittently (SIGBUS) in a loop of two-object cycles on macOS arm64 #413

Closed

Description

@blacktrs

What

tests/aot/cases/autogc_cycle_loop.php (added with the manticore-fmt fixes, #380) crashes intermittently with SIGBUS (exit 138) on macOS arm64. The program creates two-object reference cycles in a loop and references gc_collect_cycles() (so the automatic cycle collector is linked):

<?php
class A { public $o; }
if ($argc > 5) { gc_collect_cycles(); }
for ($i = 0; $i < 300000; $i++) {
    $x = new A; $y = new A;
    $x->o = $y; $y->o = $x;
}
echo "done\n";

Expected: done.

How often

  • macOS 27.0.1 arm64, binary compiled by the main compiler (515a500a) and by the site branch compiler: 3 of 6 and 4 of 5 runs exit 138, the rest print done.
  • With 3 000 000 iterations: 2 of 8 runs crash. More iterations do not make it deterministic, so the crash is not about heap growth.
  • It passes on CI (linux arm64/amd64, alpine, macOS) for the same commit, so it may be platform- or ASLR-dependent.

Why there is no tests/aot/repro/ file

xfail.sh needs a deterministic red repro; this one is random, so tools/file_bug.sh would refuse it (it passes about half the time). The case is already in tests/aot/cases/, which is where a fix would be verified. A fix needs a loop of at least ~20 runs to be believable.

Suspicion (unverified)

Two-object cycles are collected by the automatic collector during the loop; a collected-then-reused object being touched by the loop's own stores would give a bus error rather than a segfault on arm64. Worth running under MANTICORE_... gmalloc/lldb per docs/ notes ("libgmalloc OUTSIDE lldb + MANTICORE_FRAME_POINTERS=1") to get the faulting address.

Activity

  1. added
    bug
    crash
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions