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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All notable changes are documented here using Semantic Versioning. See the READM
### 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.
- 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.21; alpha.21 and alpha.22 returned without calling FrankenPHP. Worker detection itself defers a fatal error only on the worker path.

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

Expand Down
11 changes: 11 additions & 0 deletions docs/mutation-equivalence.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,14 @@ 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.

## 2026-11-30 Kept and removed interrupt hooks for the Off worker runs

No first-party C source changed. The bridge unit's Off `worker-materialize` and `worker-end`
runs now take `PROFILER_TEST_WORKER_INTERRUPT`. With `none` they serve with no
`zend_interrupt_function` and check the wrapper's `false` result with the fatal error still
pending. With `keep` they keep the sampling interrupt hook and, where sampling is supported,
require it to raise that fatal error as the call returns. The sampling unit's
`profiler_test_sampling_bailout_order()` no longer restores `EG(vm_interrupt)`, which could
drop an interrupt requested meanwhile. No compile command, context or equivalent changed;
dependency hashes renew.
15 changes: 14 additions & 1 deletion scripts/lib/RunnerRetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public static function shouldRerun(array $run, array $jobs, string $repository,
return $unassigned > 0;
}

/**
* Whether `gh api`'s output for a refused rerun request says the run is already running:
* someone reran it after it was inspected. gh prints the API message and its status.
*/
public static function alreadyRunning(string $output): bool
{
return str_contains($output, 'This workflow is already running') && str_contains($output, 'HTTP 403');
}

/**
* Reruns run $runId while shouldRerun() holds, waiting for each new attempt to complete.
* Events caused by the default token start no workflow, so a rerun's completion may not
Expand Down Expand Up @@ -103,7 +112,11 @@ public static function retry(
)) {
break;
}
if (!$rerun()) {
$accepted = $rerun();
if (!is_bool($accepted)) {
throw new \UnexpectedValueException('the rerun closure must return a bool');
}
if ($accepted === false) {
// Whoever reran it owns that attempt. A rerun by a person starts this workflow
// again when it completes; one by the default token cannot exist here, since
// this workflow's concurrency group holds one job per run.
Expand Down
24 changes: 17 additions & 7 deletions scripts/native-bailout-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,16 @@
}
echo "{$mode}: isolated automatic C bailout contract passed\n";
}
// 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) {
// Without observers only the sampling interrupt hook raises a worker wrapper's deferred
// fatal error at its call's end. With `keep`, that hook must raise it where sampling is
// supported; with `none`, 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', 'none'],
['worker-end', 'none'],
['worker-materialize', 'keep'],
['worker-end', 'keep'],
] as [$mode, $interrupt]) {
$processes = new ProcessGroups();
try {
$result = $processes->run(
Expand All @@ -114,7 +120,11 @@
'profiler_test_automatic_bailout();',
],
30,
[...Process::environment(), 'PROFILER_TEST_AUTOMATIC_BAILOUT' => $mode],
[
...Process::environment(),
'PROFILER_TEST_AUTOMATIC_BAILOUT' => $mode,
'PROFILER_TEST_WORKER_INTERRUPT' => $interrupt,
],
capture: true,
);
} finally {
Expand All @@ -126,10 +136,10 @@
], '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}",
"{$mode} without observers ({$interrupt} interrupt hook): automatic guard failed: {$result->status}: {$result->stdout}{$result->stderr}",
);
}
echo "{$mode}: worker wrapper's deferred fatal error checked without observers\n";
echo "{$mode}: worker wrapper's deferred fatal error checked without observers ({$interrupt} interrupt hook)\n";
}
foreach (['decode', 'string', 'allowed', 'resolve', 'exact', 'ini'] as $mode) {
$result = Process::run(
Expand Down
2 changes: 1 addition & 1 deletion scripts/runner-retry.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static function () use ($repository, $runId): bool {
return true;
}
// Someone reran the run after it was inspected: GitHub refuses a second rerun.
if (str_contains($result['stdout'] . $result['stderr'], 'This workflow is already running')) {
if (RunnerRetry::alreadyRunning($result['stdout'] . $result['stderr'])) {
return false;
}
throw new ProcessFailedStatus($command, $result['status'] ?? -1, $result['stderr']);
Expand Down
17 changes: 12 additions & 5 deletions tests/native/bridge-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,20 +991,27 @@ 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 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. */
* as its call returns. Without them, the sampling interrupt hook does, where the platform has
* one: PROFILER_TEST_WORKER_INTERRUPT=keep checks that. Otherwise the Off runs serve with no
* interrupt hook, so every platform sees the wrapper's FrankenPHP-typed false result and the
* still pending fatal error. The flag is then cleared. */
int profiler_sampling_supported(void);
static bool automatic_worker_keeps_interrupt(void) {
const char *value = getenv("PROFILER_TEST_WORKER_INTERRUPT");
return value && strcmp(value, "keep") == 0;
}
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())
if (!profiler_observer_setting() && !automatic_worker_keeps_interrupt())
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())
if (profiler_observer_setting() ||
(automatic_worker_keeps_interrupt() && profiler_sampling_supported()))
return bailed;
bool correct = !bailed && Z_TYPE_P(result) == IS_FALSE && profiler_flags.pending_bailout;
profiler_flags.pending_bailout = false;
Expand Down
8 changes: 4 additions & 4 deletions tests/native/c-equivalents.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "6bb397a2de8426006da8e422162c0d155ae7b5981fc78a975cfc310cc47c4863",
"docs/mutation-equivalence.md": "1f39671b39b28d5b69c6048b575b6b94d6e0c4bad225510a882a86e648b59a54",
"scripts/c-mutation-tests.sh": "fcce09b847b50ba000f7eeafed3cb3ec7953c21a407a638b7304def38d779b1e",
"scripts/link-native-faults.sh": "8b1ab21bce21fee7712239cc24b81f9be8178ea88c09ab9e1e17a4dc0f93bfe5",
"scripts/native-bailout-tests.php": "9ba64f47110d3dba88daee2ab9219eeffabb15e60abbd84d2033ff97ae797305",
"scripts/native-bailout-tests.php": "97d12d82b1ac8df1a3f9fea2d363683a8af0d57670a9327de81b298ee3a36c79",
"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": "ca2df050a5591f5888b8fd727cd981d4bac776c44ce22c29783bcd11176028b5",
"tests/native/bridge-unit.c": "3db6dc5f0922adffc342f0ce07d144e54da542c611e5e45816b021a677f7848a",
"tests/native/c-boundaries.php": "f6d339e7a6d240a368ba3f471ed9faa892b17c5d7ae6703f216084ef5ef70ef5",
"tests/native/frames-native.c": "9bd4b5ee9163bc3bb3ce41e9e9487b02f9737bb35734975b5eff9c2c971e3aff",
"tests/native/sampling-lifecycle-native.c": "83acaf91b44d5e549b6f17fcd8ab40289bee30acef0f5b36dfe662ec7312d40a",
"tests/native/sampling-unit.c": "81b03a1c97d3656014bd70ac7c9beac4cf715b1dcc52cf63aa44a57796e58347",
"tests/native/sampling-unit.c": "54beb0de09b7b64c6fab1fdb952718f7b3d131110b4ca46dbb8cc5c1c16de7d8",
"tests/support/adapter-contract.rs": "423a2de2ae754e58da8dce5f3c6766b58fc695da353e1e3fa45744ade664ee1a",
"tests/support/automatic-contract.c": "628d64d22b3ea116081f28dd2270a3202016874e744fbc2f166a1896a60d314f",
"tests/support/automatic-contract.rs": "fa6e9fa6c036e4763c27bff8601a6a02c94b5be823a20b5986d582faef458bba",
Expand Down
10 changes: 5 additions & 5 deletions tests/native/sampling-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,20 +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. */
/* The caught bailout marks the request unclean and protects the GC. Restore both, or this
* process would end on the unclean path, skipping the debug build's leak report for the
* rest of the run. The VM interrupt the deferral requested stays set: clearing it could
* also drop a sampling tick or signal requested meanwhile, and an extra interrupt is
* harmless. */
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
36 changes: 36 additions & 0 deletions tests/tools/RunnerRetryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,42 @@ function passedJobs(): array
same([1, 0, 0], [$reruns, $releases, $sleeps]);
same('quality run 7 attempt 1: already rerun elsewhere', $outcome);
},
'only gh\'s already-running refusal counts as a concurrent rerun' => static function (): void {
// gh's output for run 45456810366, whose rerun raced a manual one.
same(
true,
RunnerRetry::alreadyRunning("gh: This workflow is already running (HTTP 403)\n"
. '{"message":"This workflow is already running","status":"403"}'),
);
same(false, RunnerRetry::alreadyRunning('gh: Resource not accessible by integration (HTTP 403)'));
same(false, RunnerRetry::alreadyRunning('gh: This workflow is already running (HTTP 500)'));
same(false, RunnerRetry::alreadyRunning(''));
},
'a rerun closure without a bool result is refused' => static function (): void {
$failed = [['conclusion' => 'failure'], unassignedJobs()];
$refused = false;
try {
RunnerRetry::retry(
7,
RETRY_REPOSITORY,
static fn(string $path): mixed => (
str_ends_with($path, '/7')
? retryRun(['run_attempt' => 1])
: ['jobs' => array_map(static fn(array $job): array => [
...$job,
'run_attempt' => 1,
], $failed[1])]
),
static fn(): string => RETRY_SHA,
static function (): void {},
static function (): void {},
static function (): void {},
);
} catch (UnexpectedValueException) {
$refused = true;
}
same(true, $refused);
},
'unexpected API answers stop without a rerun' => static function (): void {
$calls = 0;
$never = static function () use (&$calls): void {
Expand Down
Loading