Skip to content

Conversation

mho22
Copy link
Collaborator

@mho22 mho22 commented Aug 4, 2025

Motivation for the change, related issues

I listed the two crashes I encountered while using Devtools in the comments.

I am currently recompiling php-wasm-node:asyncify.

Implementation details

Added the following functions in ASYNCIFY_ONLY_PREFIXED :

// NEEDED TO PREVENT THE FIRST CRASH + php_fopen_primary_script + persistent_stream_open_function + php_stream_open_for_zend + zend_error_zstr + zend_register_constant + zif_define // NEEDED TO PREVENT THE SECOND CRASH + zend_undefined_index

Testing Instructions

Based on the instructions from #2442

One test is to step into the running files 68 times until breaking on define( 'WP_DEBUG', false );. The next step would crash previously. Not anymore.

The second test is to quit the Devtools tab while it is running. It crashed previously. Not anymore.

@mho22
Copy link
Collaborator Author

mho22 commented Aug 4, 2025

While running the following code in playground/cli/src/run-cli.ts :

const path = process.cwd(); if (isPluginDirectory(path)) { playground!.run({ scriptPath: '/wordpress/index.php', }); }

I stepped into 68 times until this line in wp-config.php

define( 'WP_DEBUG', false );

And It crashed with the error below :

Error [RuntimeError]: null function or function signature mismatch at php.wasm.zend_vstrpprintf at php.wasm.zend_error at php.wasm.zend_register_constant at php.wasm.zif_define at php.wasm.ZEND_DO_ICALL_SPEC_OBSERVER_HANDLER at php.wasm.execute_ex at wasm://wasm/0012910e:wasm-function[243]:0xd0f1 at php.wasm.ZEND_INCLUDE_OR_EVAL_SPEC_OBSERVER_HANDLER at php.wasm.ZEND_USER_OPCODE_SPEC_HANDLER at php.wasm.execute_ex cause: Error at Asyncify.handleSleep at _wasm_recv at wasm://wasm/0012910e:wasm-function[574]:0x2aaca at wasm://wasm/0012910e:wasm-function[578]:0x2be60 at wasm://wasm/0012910e:wasm-function[549]:0x282e6 at wasm://wasm/0012910e:wasm-function[218]:0xab4f at php.wasm.zend_extension_statement_handler at php.wasm.zend_llist_apply_with_argument at php.wasm.ZEND_EXT_STMT_SPEC_HANDLER at php.wasm.execute_ex 

I also found a list of new functions to add in ASYNCIFY_ONLY :

+ php_fopen_primary_script + persistent_stream_open_function + php_stream_open_for_zend + zend_error_zstr + zend_register_constant + zif_define
@mho22
Copy link
Collaborator Author

mho22 commented Aug 4, 2025

New unreachable crash when quitting the tab during Devtools communication :

Error [RuntimeError]: unreachable at php.wasm.ZEND_FETCH_DIM_R_SPEC_CV_CONST_HANDLER at php.wasm.execute_ex at wasm://wasm/0012910e:wasm-function[243]:0xd0f1 at php.wasm.ZEND_DO_FCALL_SPEC_OBSERVER_HANDLER at php.wasm.execute_ex at wasm://wasm/0012910e:wasm-function[243]:0xd0f1 at php.wasm.ZEND_DO_FCALL_SPEC_OBSERVER_HANDLER at php.wasm.execute_ex at wasm://wasm/0012910e:wasm-function[243]:0xd0f1 at php.wasm.ZEND_DO_FCALL_SPEC_OBSERVER_HANDLER { cause: Error at Asyncify.handleSleep at _wasm_recv at wasm://wasm/0012910e:wasm-function[574]:0x2aaca at wasm://wasm/0012910e:wasm-function[570]:0x2a740 at wasm://wasm/0012910e:wasm-function[531]:0x2667c at wasm://wasm/0012910e:wasm-function[536]:0x26adb at wasm://wasm/0012910e:wasm-function[551]:0x2892d at wasm://wasm/0012910e:wasm-function[241]:0xce57 at php.wasm.zend_error_zstr_at at php.wasm.zend_error } 

I also found a new function to add in ASYNCIFY_ONLY :

+ zend_undefined_index
@mho22 mho22 marked this pull request as ready for review August 4, 2025 15:13
@adamziel adamziel changed the title [XDebug Bridge] Add unreachable functions to prevent crashes when using Devtools [XDebug Bridge] List additional ASYNCIFY_ONLY functions to prevent unreachable crashes when using Devtools Aug 6, 2025
@adamziel adamziel merged commit 9d06b72 into trunk Aug 6, 2025
72 of 75 checks passed
@adamziel adamziel deleted the correct-unreachable-when-running-xdebug-bridge branch August 6, 2025 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment