Skip to content

Segmentation fault on startup with custom Go extension on FrankenPHP v1.12.0 (works on v1.11.3) #2253

@pich

Description

@pich

What happened?

I can reproducibly trigger a SIGSEGV on startup when using a custom Go extension built with:

  • frankenphp extension-init
  • xcaddy build
  • php_server enabled

The crash happens with a stack based on FrankenPHP v1.12.0.
The same extension/build flow is stable with FrankenPHP v1.11.3.


Environment

  • Dockerized Linux environment
  • PHP: 8.5.x
  • Go: 1.26.x
  • xcaddy: v0.4.5
  • Caddy: v2.11.x
  • FrankenPHP module stack:
    • github.com/dunglas/frankenphp/caddy
    • github.com/dunglas/mercure/caddy
    • github.com/dunglas/vulcain/caddy
    • custom Go extension module

Reproduction Outline

  1. Generate extension glue code with:
    • frankenphp extension-init
  2. Build FrankenPHP binary with xcaddy and the custom extension module.
  3. Start FrankenPHP using a Caddyfile that includes php_server.

Example command:

frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile

Expected Behavior

FrankenPHP starts and stays running.

Actual Behavior

Process exits with SIGSEGV shortly after startup.


Backtrace (gdb excerpt)

The crash appears in PHP startup internals:

  • php_module_startup
  • zend_hash_copy

Example:

Thread received signal SIGSEGV, Segmentation fault.
0x... in zend_hash_copy () from /usr/local/lib/libphp.so
#...
#... in php_module_startup () from /usr/local/lib/libphp.so

Narrowing Results

  • Minimal Caddy config without php_server: no crash.
  • Config including php_server: crash reproduces.
  • This suggests the fault is in PHP runtime/module startup interaction, not basic Caddy parsing.

Version Comparison

Crashing setup (v1.12.0 path)

  • FrankenPHP base/image around 1.12.0
  • frankenphp/caddy@v1.12.0
  • Caddy around v2.11.2

Stable setup (v1.11.3 path)

  • dunglas/frankenphp:1.11.3-php8.5
  • frankenphp/caddy@v1.11.3
  • mercure/caddy@v0.21.8
  • vulcain/caddy@v1.2.1
  • caddy v2.11.1
  • go 1.26.0
  • xcaddy v0.4.5

With the stable set above, the service runs healthy and no SIGSEGV appears.

Build Type

Docker (Debian Trixie)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

PHP 8.5.3
Architecture: aarch64 & x86_64 (issue on both)
Thread Safety: enabled (ZTS)
OPcache: enabled
JIT: disabled
Server API: CLI
Loaded extensions:
apcu, gd, intl, pcntl, pdo_mysql, pdo_pgsql, pgsql, redis, sockets, sodium, zip

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions