Skip to content

v0.5.18 codegen regression: Fastify + MySQL binaries segfault at startup #28

Description

@proggeramlug

Summary

Binaries compiled with perry 0.5.18 that use http-server (Fastify) + database-mysql features segfault immediately on startup. The same source code compiles and runs correctly with perry 0.4.51.

Reproduction

Any TypeScript file that imports Fastify and mysql2, compiled on Linux x86_64:

perry compile main.ts -o my-server   # with perry 0.5.18
./my-server                           # SIGSEGV immediately

The same file compiled with perry 0.4.51 runs fine.

Even a minimal Fastify-only app (no MySQL) fails to start when compiled with 0.5.18 — the binary exits silently with no output.

Environment

  • Platform: Linux x86_64 (Ubuntu, Cherry Servers)
  • Perry versions tested:
    • 0.4.51 — works
    • 0.5.18 (both release binary and source-built) — segfaults
  • Runtime: Tested with both prebuilt libs and source-built (cargo build --release -p perry-runtime -p perry-stdlib). Same result.
  • Features used: crypto, database-mysql, http-server, http-client, websocket

Additional detail

When the auto-optimize feature rebuilds the runtime with the exact feature set, compilation succeeds with no linker warnings, but the resulting binary still segfaults (signal 11 / SIGSEGV) on the first instruction.

Separate issue: gc() symbol mismatch

The runtime exports the manual GC trigger as js_gc_collect (gc.rs:326), and the codegen declares it as js_gc_collect (runtime_decls.rs:1450), but calling gc() from TypeScript emits a reference to the bare symbol gc — which doesn't exist in the linked runtime. This results in:

undefined reference to `gc'

The workaround is adding a #[no_mangle] pub extern "C" fn gc() alias in gc.rs, but the codegen should either emit js_gc_collect for gc() calls, or the runtime should export the bare gc symbol.

This matters for long-running servers: without periodic gc(), the runtime's memory tracking accumulates and RSS grows unbounded, eventually causing memory corruption and crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions