Skip to content

Laravel example: ~1 in 3 starts abort in libmalloc on the first Eloquent request (write to freed memory) #568

Closed

Description

@blacktrs

Summary

The Laravel example (examples/laravel-app, PR #564) dies on roughly one process start in three at its first Eloquent request (GET /api/notes): libmalloc aborts with a corrupted free list (SIGTRAP, exit 133). Every later request on a surviving process works.

Symptoms

  • libmalloc trap in _xzm_xzone_malloc_freelist_outlined, reached from realloc in __mir_realloc_tagged (__mir_bt_frames on the first debug_backtrace, i.e. Laravel's withoutRecursion), or from __mir_array_index_build. The site moves; the corruption exists before it.
  • The corrupted free-list word is a heap pointer with bit 62 set (0x4000000000000000 is MemoryAbi::DTOR_CALLED_MASK), so something writes a flag onto a block that has already been freed.
  • Rate about 1 in 3 starts at -O 0, -O 1 and -O 2; 0 of ~14 under lldb (ASLR off). With ASan it only shows as a quarantine-recycle CHECK failure; it disappears with ASan's quarantine off.

What was ruled out

  • Double release of arrays, strings or objects (MANTICORE_DEBUG_VERIFY=1 stays silent).
  • Backtrace ring depth going negative (a trap on pop below zero never fired).
  • Pool or reference-box reuse (MANTICORE_POOL_POISON, MANTICORE_REF_QUARANTINE).
  • Client timeouts or cancelled requests (fails with wrk -c2 --timeout 60s, and on the first request).
  • Blocking-pool thread count (MANTICORE_BLOCKING_THREADS 1 / 4 / 64 fail 5/15, 1/15, 6/15).
  • The destructor registry (__mir_dtor_*): with reg / unreg / drop traced, all events are balanced. The only classes with destructors on this path are prelude ones: Resource, Fiber, Io\Poll\Context, __McPdoSqliteDrv, __McPdoSqliteStmt, WeakMap.
  • The cycle collector: no collection runs before the failing request (MANTICORE_CC_TRACE; only ~2100 dead shells sit in the root buffer).

Not reproducible with instrumentation

Calling malloc_zone_check at boot phases (20 of 20 starts fine), verify mode, lldb and a changed code layout all make the failure disappear, so this looks like a layout- or timing-sensitive write to freed memory, not a deterministic ownership error.

Reproduce

cd examples/laravel-app && composer install && cp .env.example .env && php artisan key:generate && touch database/database.sqlite && php artisan migrate
php aot/compile-views.php && manticore build -O 2
for i in $(seq 12); do WORKERS=00 ./bin/app & sleep 8; curl -s -o /dev/null -w '%{http_code}\n' localhost:8181/api/notes; kill -9 %1; done   # some print 000

Next

MallocStackLogging=1 + malloc_history on the corrupted block of a failing process, to name the allocation that was freed and still written.

Activity

  1. added
    bug
    crash
    on Nov 4, 2026
  2. blacktrs commented on Nov 9, 2026

    @blacktrs
    ContributorAuthor

    Fixed in #564: fiber stacks of 1 MiB with stack probes and a named overflow (root cause was a fiber stack overflow past the guard page). Checked on the 0.18.0 branch (#605): 12 of 12 cold starts of examples/laravel-app served the first /api/notes with 200 (the report saw ~1 in 3 abort).

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