Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes are documented here using Semantic Versioning. See the READM

## [Unreleased]

### Release note corrections

- alpha.22's published notes omitted its fixes: a deferred fatal error is raised before other extensions' VM interrupt handlers again, so an async signal handler cannot run user code after it (alpha.21 ran those handlers first); and every early return of the FrankenPHP worker wrapper on a deferred fatal error is `false`, keeping `frankenphp_handle_request()`'s `bool` type.
- alpha.23's fix concerns a fatal error already pending when a request that is not a worker's calls `frankenphp_handle_request()`: it now gets FrankenPHP's own refusal, as before alpha.22. Worker detection itself defers a fatal error only on the worker path.

## [0.1.0-alpha.23] - 2026-11-29

### Commits
Expand All @@ -20,11 +25,6 @@ All notable changes are documented here using Semantic Versioning. See the READM

- fix: type the worker wrapper's early returns and raise deferred fatals first (#106)

### Fixed

- A deferred fatal error is raised before other extensions' VM interrupt handlers again, so an async signal handler cannot run user code after it. alpha.21 ran those handlers first.
- A FrankenPHP worker call that ends on a deferred fatal error returns `false`, keeping `frankenphp_handle_request()`'s `bool` type.

## [0.1.0-alpha.21] - 2026-11-24

### Commits
Expand Down
4 changes: 2 additions & 2 deletions crates/php-profiler/src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ static ZEND_NAMED_FUNCTION(profiler_handle_request) {
* returning raises it, through the fcall end observer or the VM interrupt the
* deferral requested, before the next request's boundaries could clear it. No
* bailout leaves this frame, so its raw gcov edge counts stay exact. The result
* keeps FrankenPHP's bool return type. A request that is not a worker's still gets
* FrankenPHP's own refusal, and the bailout is raised as that call returns. */
* keeps FrankenPHP's bool return type. Detection defers only on the worker path; a
* call that is not a worker's still gets FrankenPHP's refusal with any older fatal. */
if (wrap && profiler_flags.pending_bailout)
RETURN_FALSE;
}
Expand Down
12 changes: 12 additions & 0 deletions docs/mutation-equivalence.md
Original file line number Diff line number Diff line change
Expand Up @@ -869,3 +869,15 @@ changed the test inventory: `profiler_register()`'s call to it lost its
the call returns, they check the wrapper's `false` result with that error still pending.
`automatic_worker_serve_with()` releases its strings when a bailout passes. No
compile command, context or equivalent changed; dependency hashes renew.

## 2026-11-30 Review follow-ups for the worker result tests

A comment in `profiler_handle_request()` is reworded on the same two lines; no coordinate
moves. The bridge unit's `worker-materialize` and `worker-end` runs with
`php_profiler.observer=0` now serve with no `zend_interrupt_function`, so the wrapper's `false`
result with the fatal error still pending is checked on every platform: Linux, whose sampling
interrupt hook raised it first, no longer skips that check. `scripts/native-bailout-tests.php`
passes their output to the sanitizer diagnostics check. The sampling unit's
`profiler_test_sampling_bailout_order()` restores `CG(unclean_shutdown)`, GC protection and
`EG(vm_interrupt)` after its caught bailout. No compile command, fixture symbol, context or
equivalent changed; source and dependency hashes renew.
9 changes: 7 additions & 2 deletions scripts/native-bailout-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@
}
echo "{$mode}: isolated automatic C bailout contract passed\n";
}
// Without observers only the sampling interrupt hook raises a worker wrapper's deferred
// fatal error at its call's end; where there is none, its false result is checked too.
// Without observers only the sampling interrupt hook would raise a worker wrapper's deferred
// fatal error at its call's end. The test serves with no interrupt hook, so the wrapper's
// false result and the still pending fatal error are checked on every platform.
foreach (['worker-materialize', 'worker-end'] as $mode) {
$processes = new ProcessGroups();
try {
Expand All @@ -119,6 +120,10 @@
} finally {
$processes->close();
}
$checked([
'stdout' => (string) $result->stdout,
'stderr' => (string) $result->stderr,
], 'automatic native bailout without observers');
if ($result->status !== 0 || !str_contains((string) $result->stdout, 'AUTOMATIC_C_GUARD_OK')) {
fail(
"{$mode} without observers: automatic guard failed: {$result->status}: {$result->stdout}{$result->stderr}",
Expand Down
22 changes: 17 additions & 5 deletions tests/native/bridge-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,20 @@ static PHP_FUNCTION(profiler_test_automatic_transports) {
RETURN_TRUE;
}
/* With observers, the fcall end observer raises a fatal error the worker wrapper left pending
* as its call returns; without them, the sampling interrupt hook does, where the platform has
* one. Elsewhere nothing does there, so the wrapper's FrankenPHP-typed false result and the
* still pending fatal error are visible; the flag is then cleared. */
int profiler_sampling_supported(void);
* as its call returns. Without them, the sampling interrupt hook would, where the platform has
* one; the Off runs serve with no interrupt hook instead, so every platform sees the wrapper's
* FrankenPHP-typed false result and the still pending fatal error. The flag is then cleared. */
static void (*automatic_worker_saved_interrupt)(zend_execute_data *);
static void automatic_worker_hold_interrupt(void) {
automatic_worker_saved_interrupt = zend_interrupt_function;
if (!profiler_observer_setting())
zend_interrupt_function = NULL;
}
static void automatic_worker_release_interrupt(void) {
zend_interrupt_function = automatic_worker_saved_interrupt;
}
static bool automatic_worker_deferred_result(bool bailed, zval *result) {
if (profiler_observer_setting() || profiler_sampling_supported())
if (profiler_observer_setting())
return bailed;
bool correct = !bailed && Z_TYPE_P(result) == IS_FALSE && profiler_flags.pending_bailout;
profiler_flags.pending_bailout = false;
Expand Down Expand Up @@ -1107,9 +1115,11 @@ static PHP_FUNCTION(profiler_test_automatic_bailout) {
volatile bool bailed = false;
zval result;
ZVAL_UNDEF(&result);
automatic_worker_hold_interrupt();
zend_try { result = automatic_worker_serve("automatic_test_worker_handler"); }
zend_catch { bailed = true; }
zend_end_try();
automatic_worker_release_interrupt();
automatic_fault = 0;
correct &= !strcmp(automatic_worker_log, "") && profiler_worker_handler == NULL;
correct &= automatic_worker_deferred_result(bailed, &result);
Expand All @@ -1126,9 +1136,11 @@ static PHP_FUNCTION(profiler_test_automatic_bailout) {
volatile bool bailed = false;
zval result;
ZVAL_UNDEF(&result);
automatic_worker_hold_interrupt();
zend_try { result = automatic_worker_serve("automatic_test_worker_handler"); }
zend_catch { bailed = true; }
zend_end_try();
automatic_worker_release_interrupt();
automatic_fault = 0;
correct &= !strcmp(automatic_worker_log, "e") && profiler_worker_handler == NULL;
correct &= automatic_worker_deferred_result(bailed, &result);
Expand Down
28 changes: 14 additions & 14 deletions tests/native/c-equivalents.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
"crates/php-profiler/Cargo.toml": "e7c9dfb152bcdf04c94b595fa4ac9f8f0b64ad874327c0b1dae550e26f825e95",
"crates/php-profiler/build.rs": "00165c497fd772e9612c31e718d4f0823c09bdf609b1999301fce06b3068bee2",
"crates/php-profiler/src/automatic.rs": "daa12c483db4995b5136207457d4d0043ef2a922231f49931b8c071ff8d1362a",
"crates/php-profiler/src/bridge.c": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"crates/php-profiler/src/bridge.c": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"crates/php-profiler/src/lib.rs": "5607ccfe02851ec351f363df549dabf7d2b1947601c8f4d68345c715f4e4d9c3",
"crates/php-profiler/src/sampling.c": "b9388acdd179d2de605ed139c34dcbcb8e4fdcf0425e7cb536adfbe74893341c",
"crates/php-profiler/src/sampling.rs": "c3d48f165e9f6daefb8160f5c349763736cbf64fd3367cdcafce031e79716c35",
Expand All @@ -325,19 +325,19 @@
"crates/profiler-core/src/sampling.rs": "6bf87bb08da581363024d029fd1ab5f015bb0d1621865b51f67cb99ef9f55127",
"crates/profiler-core/src/serialization.rs": "ef0c7e32063bdff9b06da9eb509b3d5cbf0cbd18e6b54ff44a92a0731c8cff5a",
"crates/profiler-core/src/storage.rs": "4565c684d24f45c1d9f449595bad8f5eab43fd1dae42ed4497c6ec80f30936f4",
"docs/mutation-equivalence.md": "c30119caf44fcf75a57f80f3d62d6b8c52eb2f540d99f8ba4715a052519c95fe",
"docs/mutation-equivalence.md": "6bb397a2de8426006da8e422162c0d155ae7b5981fc78a975cfc310cc47c4863",
"scripts/c-mutation-tests.sh": "fcce09b847b50ba000f7eeafed3cb3ec7953c21a407a638b7304def38d779b1e",
"scripts/link-native-faults.sh": "8b1ab21bce21fee7712239cc24b81f9be8178ea88c09ab9e1e17a4dc0f93bfe5",
"scripts/native-bailout-tests.php": "b34d39bffe841c885a62ca29335fae96d8b2c16fe06e9a6b01f3a96f26681a53",
"scripts/native-bailout-tests.php": "9ba64f47110d3dba88daee2ab9219eeffabb15e60abbd84d2033ff97ae797305",
"scripts/native-fault-object.php": "8217e9761d98a518f7732bf0aa1fc0ab89d5918340a413031d61cf2837ec95af",
"scripts/owned-run.php": "f24c8b688916214d8f00d70cf88996c0a98610c228475c9cfd64765e3187b24a",
"tests/native/automatic-transports.c": "17520510504be44e219522234592e3f265bbc63da41c017735d1aa33bbf99f21",
"tests/native/bailout-fault.c": "045a837fb0ca0d18e92ceba56476f67b673ce57e122350f2a3893d872983e4d2",
"tests/native/bridge-unit.c": "2330b92206d7d58a68db326719eb5a8da56e8a53051e3a3f543822270b20929e",
"tests/native/bridge-unit.c": "ca2df050a5591f5888b8fd727cd981d4bac776c44ce22c29783bcd11176028b5",
"tests/native/c-boundaries.php": "f6d339e7a6d240a368ba3f471ed9faa892b17c5d7ae6703f216084ef5ef70ef5",
"tests/native/frames-native.c": "9bd4b5ee9163bc3bb3ce41e9e9487b02f9737bb35734975b5eff9c2c971e3aff",
"tests/native/sampling-lifecycle-native.c": "83acaf91b44d5e549b6f17fcd8ab40289bee30acef0f5b36dfe662ec7312d40a",
"tests/native/sampling-unit.c": "79b698377743d13f0b0d68a86e4c9fa50307381e237b77247b8b7e82f6e4c590",
"tests/native/sampling-unit.c": "81b03a1c97d3656014bd70ac7c9beac4cf715b1dcc52cf63aa44a57796e58347",
"tests/support/adapter-contract.rs": "423a2de2ae754e58da8dce5f3c6766b58fc695da353e1e3fa45744ade664ee1a",
"tests/support/automatic-contract.c": "628d64d22b3ea116081f28dd2270a3202016874e744fbc2f166a1896a60d314f",
"tests/support/automatic-contract.rs": "fa6e9fa6c036e4763c27bff8601a6a02c94b5be823a20b5986d582faef458bba",
Expand All @@ -346,7 +346,7 @@
"equivalents": [
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand All @@ -367,7 +367,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand All @@ -388,7 +388,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand All @@ -409,7 +409,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand All @@ -430,7 +430,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand All @@ -451,7 +451,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_init_const",
"location": {
"start": {
Expand All @@ -472,7 +472,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_init_const",
"location": {
"start": {
Expand All @@ -493,7 +493,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_remove_void_call",
"location": {
"start": {
Expand Down Expand Up @@ -813,7 +813,7 @@
},
{
"source": "crates/php-profiler/src/bridge.c",
"source_sha256": "62f7cce13767b45be9229dbdca1e1956bf18c3cf97c172d12ce1405843aff765",
"source_sha256": "d27d1262f8c6f1a2067fca5bc22c117e14cd2e190f2e0d060e0029433c7c5f35",
"mutatorName": "cxx_assign_const",
"location": {
"start": {
Expand Down
9 changes: 9 additions & 0 deletions tests/native/sampling-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,11 +1427,20 @@ static ZEND_FUNCTION(profiler_test_sampling_bailout_order) {
void (*original_previous)(zend_execute_data *) = previous_interrupt;
previous_interrupt = sampling_test_previous_handler;
sampling_test_late_calls = 0;
/* The caught bailout marks the request unclean and protects the GC; the deferral left the
* VM interrupt requested. Restore all three, or this process would end on the unclean path,
* skipping the debug build's leak report for the rest of the run. */
bool unclean = CG(unclean_shutdown);
bool gc_protected_before = gc_protected();
bool interrupt = zend_atomic_bool_load_ex(&EG(vm_interrupt));
automatic_test_defer_bailout();
volatile bool bailed = false;
zend_try { sample_interrupt(EG(current_execute_data)); }
zend_catch { bailed = true; }
zend_end_try();
CG(unclean_shutdown) = unclean;
gc_protect(gc_protected_before);
zend_atomic_bool_store_ex(&EG(vm_interrupt), interrupt);
previous_interrupt = original_previous;
RETURN_LONG(bailed && sampling_test_late_calls == 0);
#else
Expand Down
Loading