-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP: Explore building with pthreads #346
Conversation
@adamziel I experienced a similar issue when I tried to save a post in the wp-now environment for my blog. Is this PR ready to test? Do you know a way to check which function causes the crash? |
This PR is not ready to test at all, unfortunately. It's at a stage where it builds, which is good progress and much further than I ever got before, but it doesn't run yet. I haven't prioritized finishing this PR – I just wanted to make it public for anyone interested to play with. If you'd like to take a stab at pthreads support, you're more than welcome to! |
You mean with this PR applied? Or in a vanilla wp-now environment? If it's the latter, would you create a separate issue to track it? We'd need to build PHP with debugging symbols and spend some time in dev tools to pinpoint where exactly is it crashing. |
Yes, I was wondering if testing this PR against my blog makes sense to see if it still crashes. It's clear to me now that it's not finished yet.
Yes, I've added #416 |
Adding a
|
…395) ## What? - Add the `executeWPCli` function to download and execute `wp-cli. - In the future, we may include the command `wp-now wp`. Currently, we drop it out until we improve the pthreads execution. Currently a PR in progress: #346 - Surface `emscriptenOptions` to catch print and print error for `wp-cli` execution. ## Why? - See https://github.com/WordPress/wordpress-playground/issues/269 ## How? It downloads the wp-cli.phar file if the file doesn't exist, then uses `php.cli()` to execute it. There are some limitations in the `wp-cli` features. Some of them may not work. ## Testing Instructions - Check out this branch. - Copy your path to your theme or plugin - After installing and building the project, run: - Run the tests `npx nx test wp-now` - Observe the tests pass. <!--details> <summary>~`WP_NOW_PROJECT_PATH=/path/to/your-theme-or-plugin npx nx preview wp-now wp user list`~ </summary> ``` > nx run wp-now:preview wp user list +----+------------+--------------+--------------+--------------+---------------+ | ID | user_login | display_name | user_email | user_registe | roles | | | | | | red | | +----+------------+--------------+--------------+--------------+---------------+ | 1 | admin | admin | admin@localh | 2023-05-19 1 | administrator | | | | | ost.com | 7:33:35 | | +----+------------+--------------+--------------+--------------+---------------+ > NX Successfully ran target preview for project wp-now and 12 tasks it depends on (10s) With additional flags: wp user list ``` </details!--> --------- Co-authored-by: Daniel Bachhuber <daniel.bachhuber@automattic.com>
Turns out pthreads support is completely unrelated to pcntl and |
…(#395) ## What? - Add the `executeWPCli` function to download and execute `wp-cli. - In the future, we may include the command `wp-now wp`. Currently, we drop it out until we improve the pthreads execution. Currently a PR in progress: WordPress/wordpress-playground#346 - Surface `emscriptenOptions` to catch print and print error for `wp-cli` execution. ## Why? - See https://github.com/WordPress/wordpress-playground/issues/269 ## How? It downloads the wp-cli.phar file if the file doesn't exist, then uses `php.cli()` to execute it. There are some limitations in the `wp-cli` features. Some of them may not work. ## Testing Instructions - Check out this branch. - Copy your path to your theme or plugin - After installing and building the project, run: - Run the tests `npx nx test wp-now` - Observe the tests pass. <!--details> <summary>~`WP_NOW_PROJECT_PATH=/path/to/your-theme-or-plugin npx nx preview wp-now wp user list`~ </summary> ``` > nx run wp-now:preview wp user list +----+------------+--------------+--------------+--------------+---------------+ | ID | user_login | display_name | user_email | user_registe | roles | | | | | | red | | +----+------------+--------------+--------------+--------------+---------------+ | 1 | admin | admin | admin@localh | 2023-05-19 1 | administrator | | | | | ost.com | 7:33:35 | | +----+------------+--------------+--------------+--------------+---------------+ > NX Successfully ran target preview for project wp-now and 12 tasks it depends on (10s) With additional flags: wp user list ``` </details!--> --------- Co-authored-by: Daniel Bachhuber <daniel.bachhuber@automattic.com>
This PR attempts to add pthreads
and pcntl support necessary to handle pcntl_fork. Full PHPUnit support hinges on this, and AFAIR there's a few wp-cli commands also relying on threads.Pthreads support doesn't seem to be necessary for any mission-critical PHP feature or package. I used to think it is required to supportfork()
, but that's not actually the case.I disabled all the extensions and got vanilla PHP to build. Unfortunately, the basic test.js file included in the PR leads to the following error:
The error happens inside
php_request_startup()
. If I compile just PHP 7.4 withoutphp_wasm.c
and runzend_eval_string(code, NULL, "php-wasm run script")
, the error turns into Bus Error – which is also what happens ifeval
is triggered via_run_php
inphp_wasm.c
.I wonder if
-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
would help.Related WordPress/playground-tools#25
cc @dmsnell @danielbachhuber @sejas