File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,14 @@ static ZEND_METHOD(_ZendTestFiber, start)
247247 Z_PARAM_VARIADIC_WITH_NAMED (params , param_count , named_params );
248248 ZEND_PARSE_PARAMETERS_END ();
249249
250- ZEND_ASSERT (fiber -> context .status == ZEND_FIBER_STATUS_INIT );
250+ if (fiber -> context .status != ZEND_FIBER_STATUS_INIT ) {
251+ zend_string * fiber_error_name = ZSTR_INIT_LITERAL ("fibererror" , false);
252+ zend_class_entry * fiber_error_ce = zend_lookup_class_ex (fiber_error_name , fiber_error_name , 0 );
253+ ZEND_ASSERT (fiber_error_ce );
254+ zend_throw_error (fiber_error_ce , "Cannot start a fiber that has already been started" );
255+ zend_string_release_ex (fiber_error_name , false);
256+ RETURN_THROWS ();
257+ }
251258
252259 if (fiber -> previous != NULL ) {
253260 zend_throw_error (NULL , "Cannot start a fiber that is the target of another fiber" );
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-16496: _ZendTestFiber failed assertion when started twice
3+ --EXTENSIONS--
4+ zend_test
5+ --FILE--
6+ <?php
7+
8+ $ test = new _ZendTestFiber (function () {});
9+ $ test ->start ();
10+
11+ try {
12+ $ test ->start ();
13+ } catch (FiberError $ e ) {
14+ echo $ e ->getMessage (), "\n" ;
15+ }
16+
17+ ?>
18+ --EXPECT--
19+ Cannot start a fiber that has already been started
You can’t perform that action at this time.
0 commit comments