Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: Static PHP 8.5 x86_64 (herd-lite) SIGILL / "Illegal instruction" (exit 132) on CPUs without ADX (e.g. Intel Haswell i7-4790) — GMP built with ADX enabled

Aperta
#1,747 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
build-system

Direzione di ricerca

Inizia con la configurazione di build della distribuzione PHP statica e le impostazioni di compilazione di GMP 6.3.0, quindi esegui lo script repro_gmp.php fornito su una CPU della classe Haswell. Verifica se le istruzioni ADX sono abilitate senza gating a runtime e verifica che un binario ricompilato completi gmp_mul senza SIGILL su CPU prive di ADX.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

macOS
Platform

macOS

Operating system version

Linux 6.14.8-2-pve (Proxmox), x86_64

System architecture

Intel (x86)

Herd Version

laravel 13

PHP Version

php 8.5.0 (cli), NTS, Nov 20 2025

Bug description

Summary

A prebuilt static PHP 8.5.0 binary from your distribution crashes with SIGILL / Illegal instruction (exit 132) on any CPU that lacks the ADX instruction set — for example an Intel Core i7-4790 (Haswell). The crash is inside GMP 6.3.0's big-number multiplication (mpn_mul_1), which was compiled with ADX (adcx/adox) and BMI2 (mulx) enabled and shipped without a runtime CPUID gate. Haswell has BMI2 but no ADX, so the ADX instruction stream faults.

This is a broad compatibility problem: it will crash on every pre-Broadwell Intel (Sandy Bridge → Haswell) and many older/lower-end AMD parts, on a completely ordinary gmp_mul() call.

Environment

  • Host CPU: Intel Core i7-4790 @ 3.60GHz (Haswell)
    • has: bmi1 bmi2 avx2 sse4_2 — adx ABSENT
  • OS: Linux 6.14.8-2-pve (Proxmox), x86_64
  • Binary: php 8.5.0 (cli), NTS, x86_64-linux-musl-gcc, static, stripped
    • Built by Beyond Code for php.new, Nov 20 2025
    • GMP 6.3.0 (static), OpenSSL 3.6.0 (static)
  • Thread safety: disabled

Root cause (build-time)

Your static build compiled the bundled GMP with ADX enabled (the shipped object contains adcx/adox), but shipping it that way is only safe if a runtime CPUID check selects the ADX path; otherwise it faults on any non-ADX CPU. The GMP code path here has BMI2+ADX instructions reachable unconditionally on the affected CPUs.

Suggested fix

  • Rebuild GMP for the static PHP distribution without ADX — most simply --disable-assembly (GMP then uses its portable C path), or ensure the compile flags do not enable -madx/-march for the GMP low-level multiply objects.
  • Ideally ensure GMP's runtime CPU detection (its .asm mulx/ADX variants gate on the CPUID ADX bit) is actually being used, rather than a fixed instruction stream.
  • Re-test on a Haswell-class CPU (i7-4xxx / Xeon E3 v3) after rebuilding.

Impact

Any deployment of this static PHP build on hardware older than ADX support (roughly pre-2015 Intel Broadwell and many older AMD CPUs) will crash during ordinary big-number arithmetic (gmp_mul, and any library built on it, e.g. phpseclib BigInteger). This makes the distributed binary unusable on a large class of still-common servers/VMs.


*Separate root-cause report filed with GMP upstream.

Steps to reproduce

Reproducer (self-contained, no external libs)

<?php
$a = gmp_init(str_repeat('12345678901234567890', 40), 10);
$b = gmp_init(str_repeat('98765432109876543210', 40), 10);
$r = gmp_mul($a, $b);
echo gmp_strval($r, 10), "\n";

Run:

/path/to/php repro_gmp.php

Observed:

Illegal instruction
(exit code 132)

The size is chosen to force the multi-limb ADX multiply path; smaller multiplications that stay in a single-limb path may not fault, which is why this can appear intermittent.

Relevant log output
Illegal instruction
(exit code 132)
Lingua principale
Nessun dato sulla lingua
Stelle
124
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di beyondcode/herd-community

Tutte le issue di beyondcode/herd-community

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.