Asyncify: Add few more function names#3037
Asyncify: Add few more function names#3037Utsav-Ladani wants to merge 13 commits intoWordPress:trunkfrom
Conversation
|
@Utsav-Ladani thank you for contributing! @bgrgicak would you be able to review? |
|
@adamziel I tried building this for asyncify Node and it's still showing me same error. I guess more functions are missed from this list. Is there any standard way to find such function using any tool? |
|
@Utsav-Ladani Unfortunately, we don't have any standardized tool. working with these Asyncify problems is notoriously difficult. That being said, this doc page may be helpful in here: https://wordpress.github.io/wordpress-playground/developers/architecture/wasm-asyncify/#fixing-asyncify-crashes Be sure to also check the linked resources is that there's more potentially helpful content in there. |
99c2a97 to
7194c27
Compare
|
Thanks @adamziel and @bgrgicak for helpful insights. It was related to wrapping the {
"landingPage": "/wp-admin/plugins.php",
"preferredVersions": {
"php": "7.4",
"wp": "5.9"
},
"steps": [
{
"step": "login",
"username": "admin"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/plugins/crash-php-wasm.php",
"data": {
"resource": "url",
"url": "https://gist.githubusercontent.com/bgrgicak/faad52a34f909306c82800a76a936da5/raw/6e836dccb28876eec07f6dbbe588e56b8c76b0aa/php-wasm-crash.php"
}
},
{
"step": "activatePlugin",
"pluginPath": "/wordpress/wp-content/plugins/crash-php-wasm.php"
}
],
"features": {},
"login": true
}Additionally, this PR fixes a bunch of other PHP magic methods like Now the only issue is that when a method has an async call like To test that behavior, run the following code with <?php
/**
* Comprehensive PHP Magic Methods Demo
* This class demonstrates all PHP magic methods
*/
class MagicDemo
{
private $name;
public function __construct($name)
{
$this->name = $name;
}
public function __destruct()
{
echo "__destruct() called for: {$this->name}\n";
}
public function __clone()
{
$this->name = $this->name . " (cloned)";
file_get_contents("https://gist.githubusercontent.com/bgrgicak/faad52a34f909306c82800a76a936da5/raw/php-wasm-crash.php");
echo "__clone() called\n";
}
}
$obj = new MagicDemo("MyObject");
$clonedObj = clone $obj;Also, let me know the flow to recompile the PHP files. |
|
Great work @Utsav-Ladani 🚀
Could you please add this test and other test examples you mentioned to php-part-2.spec.ts? For testing, I suggest that you recompile one PHP version and run the tests using
I usually run |
|
Such a good work here @Utsav-Ladani, thank you for taking on this challenging fix! |
32605ee to
10a705b
Compare
|
I've added unit tests to I updated the Dockerfile based on the errors I encountered. Currently, with PHP Let me know how to analyze and fix such errors. |
|
@Utsav-Ladani Asyncify is very tricky in that way. If you've listed all the functions and it still throws an error, I'd poke around with setting a breakpoint, stepping over a few calls and seeing if any other function appears. Also, adding an occasional That being said, this PR already makes things a lot better and I would be super happy to get this merged even if |
6e4d212 to
275332d
Compare
|
I'm recomiling it now.
When this happens to me, I'm usually able to work around it by pruning data and running web and Node recompiles separately ( |
|
@Utsav-Ladani I recompiled PHP-wasm and there are some test errors with file_get_contents. Would you have some time to take a look at it? |
|
Thanks @bgrgicak for your help. Finally, I am able to recompile everything with your docker prune trick. I updated However, it's only failing when |
@mho22 do you have any tips on how to debug these test failures? |
|
I tried to analyze what versions and environments caused these crashes
the first one reproduces This may help. Another one would be to run The second error You should first fix the |
|
Thanks @mho22 for guiding me. I am able to fix errors related to PHP 8.5 and 5.4 w/o xdebug. For PHP 7.2, support is dropped, so no need to fix it. For crash related unit test, we are triggering network call inside clone method which crashes the process and then we test unhandled rejection, but since this PR fixes that edge case and allows to trigger network calls from clone method, it's failing. We need different test case to test the process crash. |
|
@Utsav-Ladani Great work! Two last issues !
The It will maybe return a more complete list of functions with the missing one(s) in it.
|
|
@mho22 I debugged as you suggested and I get following functions in trace, I believe those are related to xdebug. Do I have to recompile xdebug? However, those tests are still failing. "zif_xdebug_var_dump",\
"xdebug_dbgp_init",\
"xdebug_debug_init_if_requested_at_startup",\
"xdebug_objdebug_pp",\
"xdebug_get_zval_value_text_ansi",\
As per code,
|
|
@Utsav-Ladani You don't have to recompile Xdebug. You found a tricky one. I remember trying to fix similar issues by calling And for the second point, I hadn't seen the skip option. So yes, we'll need to figure out what could provoke another Asyncify crash. WDYT @adamziel @bgrgicak @brandonpayton ? |
|
We could choose a different code path for PHP 8.5+ or just leave this test disabled in these newer PHP versions. JSPI in Safari will hopefully land before PHP 8.6 or 8.7 at the latest. |
|
I'm sorry @adamziel, the issue is more related to the PHP versions < 8.5 tests not catching gracefully the Asyncify error anymore because this pull request seems to fix the crash. Could this be possible? |
|
Aha, gotcha! Listing |
|
@Utsav-Ladani I couldn't help but try this pull request locally, but it was full of oddly linted files. I decided to recreate the pull request based on only two files :
And I finally found out what was causing |
|
@mho22 Thanks for taking care of remaining issues. Curious to know what was the actual issue. |
|
Thanks to your work, we were able to run the In That said, since @brandonpayton implemented the multi-worker pull request, we've been experiencing other crashes, so the pull request is not complete yet. |
## Motivation for the change, related issues Reproduces issues from pull request : #3037 Related to issue : #2957 Thanks to the great work by @Utsav-Ladani, I was able to figure out the remaining errors. ## Implementation details - Add list of asyncify functions discovered by @Utsav-Ladani - Improving test file. ## Testing Instructions (or ideally a Blueprint) CI --------- Co-authored-by: Brandon Payton <brandon@happycode.net>
|
It is now merged. Thanks again @Utsav-Ladani for your pull request. I will close this one now. |

Motivation for the change, related issues
Testing whether this fix the issue #2957
Implementation details
Adding few functions. Check code change for function names.
Testing Instructions (or ideally a Blueprint)
N/A