Skip to content

fix!: keep Rust panics on the Rust side of the FFI boundary - #786

Merged
ptondereau merged 5 commits into
masterfrom
fix/ffi-panic-policy
Sep 20, 2026
Merged

ptondereau merged 5 commits into
masterfrom
fix/ffi-panic-policy

Conversation

@ptondereau

Copy link
Copy Markdown
Member

Description

A Rust panic reached from PHP is now caught at every entry point the crate writes (generated handlers, constructors, closures, object handlers) and thrown as a PHP Error with the message Rust panic: <message>, instead of aborting the PHP process; PhpException::throw is infallible, try_catch reports CatchError::Panic, and a failing module startup returns the real Zend FAILURE so PHP refuses to start the module. Hooks and raw extern "C" callbacks the user hands to the engine still abort, which the guide and the v0.16 migration guide now document.

Checklist

@coveralls

coveralls commented Sep 20, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 35506326831

Coverage decreased (-0.1%) to 69.349%

Details

  • Coverage decreased (-0.1%) from the base build.
  • Patch coverage: 102 uncovered changes across 9 files (71 of 173 lines covered, 41.04%).
  • 14 coverage regressions across 6 files.

Uncovered Changes

File Changed Covered %
src/zend/handlers.rs 48 0 0.0%
src/closure.rs 17 0 0.0%
src/zend/try_catch.rs 40 27 67.5%
src/exception.rs 8 0 0.0%
src/internal/mod.rs 33 27 81.82%
src/builders/class.rs 4 0 0.0%
src/zend/ce.rs 3 0 0.0%
src/convert.rs 2 0 0.0%
src/php_eval.rs 1 0 0.0%
Total (11 files) 173 71 41.04%

Coverage Regressions

14 previously-covered lines in 6 files lost coverage.

File Lines Losing Coverage Coverage
src/exception.rs 5 83.55%
src/builders/class.rs 2 77.44%
src/closure.rs 2 20.19%
src/php_eval.rs 2 97.04%
src/zend/handlers.rs 2 0.0%
src/zend/try_catch.rs 1 89.51%

Coverage Stats

Coverage Status
Relevant Lines: 13771
Covered Lines: 9550
Line Coverage: 69.35%
Coverage Strength: 43.49 hits per line

💛 - Coveralls

@codspeed

codspeed Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 30 untouched benchmarks


Comparing fix/ffi-panic-policy (7543b95) with master (645078e)

Open in CodSpeed

@ptondereau
ptondereau marked this pull request as ready for review September 20, 2026 11:32
@ptondereau
ptondereau merged commit 894334a into master Sep 20, 2026
72 checks passed
@ptondereau
ptondereau deleted the fix/ffi-panic-policy branch September 20, 2026 14:24
@Xenira Xenira mentioned this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants