Skip to content

Commit

Permalink
Probably fixed flaky tests waiting on collect()
Browse files Browse the repository at this point in the history
this is a sus fix, and it's still possible for new tasks to get added between the task crashing and the worker getting flagged as crashed.
however, this ensures that the worker's state will be consistent with the tasks collected by collect() so that collect() can properly detect errors.
this theoretically fixes workers-no-submit-after-task-crash.phpt flaking under valgrind.
  • Loading branch information
dktapps committed Apr 2, 2024
1 parent f98dd0e commit a4fe5a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routine.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@ static void* pmmpthread_routine(pmmpthread_routine_arg_t* routine) {
zval connection;
pmmpthread_object_connect(PMMPTHREAD_FETCH_FROM(Z_OBJ(original)), &connection);
zend_result task_result = pmmpthread_routine_run_function(PMMPTHREAD_FETCH_FROM(Z_OBJ(connection)));
if (task_result == FAILURE) {
//this needs to happen before we put the crashed task on the GC queue
//so that waiting on collect() can reliably detect errors
//this ensures that tests like workers-no-submit-after-task-crash.phpt work correctly
pmmpthread_monitor_add(&ts_obj->monitor, PMMPTHREAD_MONITOR_ERROR);
}
pmmpthread_worker_add_garbage(thread->worker_data, &done_tasks_cache, &connection);
zval_ptr_dtor(&connection);

if (task_result == FAILURE) {
//we may have run out of memory or some error that left the interpreter in an unusable state
pmmpthread_monitor_add(&ts_obj->monitor, PMMPTHREAD_MONITOR_ERROR);
break;
}
}
Expand Down

0 comments on commit a4fe5a8

Please sign in to comment.