Skip to content
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

Error: "unreachable" WASM instruction executed #1147

Closed
remcotolsma opened this issue Mar 27, 2024 · 5 comments · Fixed by #1181
Closed

Error: "unreachable" WASM instruction executed #1147

remcotolsma opened this issue Mar 27, 2024 · 5 comments · Fixed by #1181
Assignees
Labels
[Feature] PHP.wasm [Type] Bug An existing feature does not function as intended
Milestone

Comments

@remcotolsma
Copy link

remcotolsma commented Mar 27, 2024

The following code causes an Error: "unreachable" WASM instruction executed.:

\add_action(
	'init',
	function() {
		$data = new class() implements \IteratorAggregate {
			public function getIterator(): \Traversable {
				\wp_remote_get( 'https://httpbin.org/get' );

				$test = [
					'option 1',
					'option 2',
					'option 3',
				];

				return new \ArrayIterator( $test );
			}
		};

		$test = [
			(object) [ 'label' => '— Choose —' ],
			...$data
		];
	}
);

npx wp-now start --php 8.3
Starting the server......
directory: /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms
mode: plugin
php: 8.3
wp: latest
WordPress latest folder already exists. Skipping download.
SQLite folder already exists. Skipping download.
Server running at http://localhost:8881
Trace: Error:
"unreachable" WASM instruction executed.

The typical reason is a PHP function missing from the ASYNCIFY_ONLY
list when building PHP.wasm.

You will need to file a new issue in the WordPress Playground repository
and paste this error message there:

https://github.com/WordPress/wordpress-playground/issues/new

If you're a core developer, the typical fix is to:

* Isolate a minimal reproduction of the error
* Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository
* Run 'npm run fix-asyncify'
* Commit the changes, push to the repo, release updated NPM packages

Below is a list of all the PHP functions found in the stack trace to
help with the minimal reproduction. If they're all already listed in
the Dockerfile, you'll need to trigger this error again with long stack
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
CLI option:

    * php_pollfd_for
    * php_network_connect_socket
    * php_tcp_sockop_set_option
    * php_openssl_sockop_set_option
    * _php_stream_set_option
    * _php_stream_xport_create
    * zif_stream_socket_client
    * ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER
    * execute_ex
    * zend_call_function

    at #handleRequest (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69312:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _NodePHP.run (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69045:14)
    at async #dispatchToPHP (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68581:14)
    at async PHPRequestHandler.request (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68484:14)
    at async PHPBrowser.request (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68326:22)
    at async file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-now/wp-now/main.js:912:20 {
  cause: Error: Rethrown
      at UnhandledRejectionsTarget.errorListener (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69278:28)
      at [nodejs.internal.kHybridDispatch] (node:internal/event_target:822:20)
      at UnhandledRejectionsTarget.dispatchEvent (node:internal/event_target:757:26)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68069:20)
      at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
      at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836)
      at dynCall_ii (wasm://wasm/02b5939a:wasm-function[12431]:0x65fa1a)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at invoke_ii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10533:14)
      at wasm_sapi_handle_request (wasm://wasm/02b5939a:wasm-function[9415]:0x554538)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at Object.ccall (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9955:20)
      at exitCode (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69287:53)
      at new Promise (<anonymous>) {
    cause: RuntimeError: unreachable
        at zend_std_write_property (wasm://wasm/02b5939a:wasm-function[994]:0x92d14)
        at zend_default_exception_new (wasm://wasm/02b5939a:wasm-function[9040]:0x5415c5)
        at object_init_ex (wasm://wasm/02b5939a:wasm-function[191]:0x12787)
        at zend_throw_exception_zstr (wasm://wasm/02b5939a:wasm-function[3283]:0x21258a)
        at zend_throw_exception (wasm://wasm/02b5939a:wasm-function[224]:0x1614e)
        at zend_throw_exception_ex (wasm://wasm/02b5939a:wasm-function[139]:0xaeab)
        at zend_user_it_get_new_iterator (wasm://wasm/02b5939a:wasm-function[8916]:0x5372d5)
        at ZEND_ADD_ARRAY_UNPACK_SPEC_HANDLER (wasm://wasm/02b5939a:wasm-function[13993]:0x6df9c1)
        at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
        at zend_execute (wasm://wasm/02b5939a:wasm-function[3335]:0x216beb)
        at zend_execute_scripts (wasm://wasm/02b5939a:wasm-function[9030]:0x540a71)
        at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
        ... 2 lines matching cause stack trace ...
        at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
        at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836) {
      cause: Error
          at Asyncify.handleSleep (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10749:45)
          at _wasm_poll_socket (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9627:21)
          at php_pollfd_for (wasm://wasm/02b5939a:wasm-function[967]:0x90aa8)
          at php_network_connect_socket (wasm://wasm/02b5939a:wasm-function[5415]:0x397c22)
          at php_tcp_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10486]:0x5a4e76)
          at php_openssl_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10621]:0x5b04ec)
          at _php_stream_set_option (wasm://wasm/02b5939a:wasm-function[487]:0x35fda)
          at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
          at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
          at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
          at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
          at _php_stream_xport_create (wasm://wasm/02b5939a:wasm-function[1712]:0xf1fa3)
          at zif_stream_socket_client (wasm://wasm/02b5939a:wasm-function[7893]:0x4b9abe)
          at ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02b5939a:wasm-function[13744]:0x6c0798)
          at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
          at zend_call_function (wasm://wasm/02b5939a:wasm-function[462]:0x32c3a)
    },
    betterMessage: '\n' +
      '"unreachable" WASM instruction executed.\n' +
      '\n' +
      'The typical reason is a PHP function missing from the ASYNCIFY_ONLY\n' +
      'list when building PHP.wasm.\n' +
      '\n' +
      'You will need to file a new issue in the WordPress Playground repository\n' +
      'and paste this error message there:\n' +
      '\n' +
      'https://github.com/WordPress/wordpress-playground/issues/new\n' +
      '\n' +
      "If you're a core developer, the typical fix is to:\n" +
      '\n' +
      '* Isolate a minimal reproduction of the error\n' +
      '* Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository\n' +
      "* Run 'npm run fix-asyncify'\n" +
      '* Commit the changes, push to the repo, release updated NPM packages\n' +
      '\n' +
      'Below is a list of all the PHP functions found in the stack trace to\n' +
      "help with the minimal reproduction. If they're all already listed in\n" +
      "the Dockerfile, you'll need to trigger this error again with long stack\n" +
      'traces enabled. In node.js, you can do it using the --stack-trace-limit=100\n' +
      'CLI option: \n' +
      '\n' +
      '    * php_pollfd_for\n' +
      '    * php_network_connect_socket\n' +
      '    * php_tcp_sockop_set_option\n' +
      '    * php_openssl_sockop_set_option\n' +
      '    * _php_stream_set_option\n' +
      '    * _php_stream_xport_create\n' +
      '    * zif_stream_socket_client\n' +
      '    * ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER\n' +
      '    * execute_ex\n' +
      '    * zend_call_function\n'
  }
}
    at file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-now/wp-now/main.js:919:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)


  WASM ERROR
  table index is out of bounds

wasm://wasm/02b5939a:1


RuntimeError: table index is out of bounds
    at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
    ... 2 lines matching cause stack trace ...
    at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
    at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836)
    at dynCall_ii (wasm://wasm/02b5939a:wasm-function[12431]:0x65fa1a)
    at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
    at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
    at invoke_ii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10533:14)
    at wasm_sapi_handle_request (wasm://wasm/02b5939a:wasm-function[9415]:0x554538)
    at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
    at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
    at Object.doRewind (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9845:14)
    at /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9868:45
    at /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9694:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error
      at Asyncify.handleSleep (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10749:45)
      at _wasm_poll_socket (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9627:21)
      at php_pollfd_for (wasm://wasm/02b5939a:wasm-function[967]:0x90aa8)
      at php_network_connect_socket (wasm://wasm/02b5939a:wasm-function[5415]:0x397c22)
      at php_tcp_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10486]:0x5a4e76)
      at php_openssl_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10621]:0x5b04ec)
      at _php_stream_set_option (wasm://wasm/02b5939a:wasm-function[487]:0x35fda)
      at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
      at _php_stream_xport_create (wasm://wasm/02b5939a:wasm-function[1712]:0xf1fa3)
      at zif_stream_socket_client (wasm://wasm/02b5939a:wasm-function[7893]:0x4b9abe)
      at ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02b5939a:wasm-function[13744]:0x6c0798)
      at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
      at zend_call_function (wasm://wasm/02b5939a:wasm-function[462]:0x32c3a)
}

Node.js v21.6.2
➜  wp-pronamic-pay-with-mollie-for-gravity-forms git:(main) ✗ npx wp-now start --php 8.3
Starting the server......
directory: /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms
mode: plugin
php: 8.3
wp: latest
WordPress latest folder already exists. Skipping download.
SQLite folder already exists. Skipping download.
Error:
"unreachable" WASM instruction executed.

The typical reason is a PHP function missing from the ASYNCIFY_ONLY
list when building PHP.wasm.

You will need to file a new issue in the WordPress Playground repository
and paste this error message there:

https://github.com/WordPress/wordpress-playground/issues/new

If you're a core developer, the typical fix is to:

* Isolate a minimal reproduction of the error
* Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository
* Run 'npm run fix-asyncify'
* Commit the changes, push to the repo, release updated NPM packages

Below is a list of all the PHP functions found in the stack trace to
help with the minimal reproduction. If they're all already listed in
the Dockerfile, you'll need to trigger this error again with long stack
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
CLI option:

    * php_pollfd_for
    * php_network_connect_socket
    * php_tcp_sockop_set_option
    * php_openssl_sockop_set_option
    * _php_stream_set_option
    * _php_stream_xport_create
    * zif_stream_socket_client
    * ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER
    * execute_ex
    * zend_call_function

    at #handleRequest (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69312:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _NodePHP.run (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69045:14)
    at async #dispatchToPHP (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68581:14)
    at async PHPRequestHandler.request (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68484:14)
    at async PHPBrowser.request (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68326:22)
    at async ca (file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-playground/blueprints/index.js:1406:95)
    at async startWPNow (file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-now/wp-now/main.js:607:3)
    at async startServer (file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-now/wp-now/main.js:873:42)
    at async Object.handler (file:///Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@wp-now/wp-now/main.js:1069:25) {
  cause: Error: Rethrown
      at UnhandledRejectionsTarget.errorListener (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69278:28)
      at [nodejs.internal.kHybridDispatch] (node:internal/event_target:822:20)
      at UnhandledRejectionsTarget.dispatchEvent (node:internal/event_target:757:26)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68069:20)
      at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
      at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836)
      at dynCall_ii (wasm://wasm/02b5939a:wasm-function[12431]:0x65fa1a)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at invoke_ii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10533:14)
      at wasm_sapi_handle_request (wasm://wasm/02b5939a:wasm-function[9415]:0x554538)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at Object.ccall (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9955:20)
      at exitCode (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:69287:53)
      at new Promise (<anonymous>) {
    cause: RuntimeError: unreachable
        at zend_std_write_property (wasm://wasm/02b5939a:wasm-function[994]:0x92d14)
        at zend_default_exception_new (wasm://wasm/02b5939a:wasm-function[9040]:0x5415c5)
        at object_init_ex (wasm://wasm/02b5939a:wasm-function[191]:0x12787)
        at zend_throw_exception_zstr (wasm://wasm/02b5939a:wasm-function[3283]:0x21258a)
        at zend_throw_exception (wasm://wasm/02b5939a:wasm-function[224]:0x1614e)
        at zend_throw_exception_ex (wasm://wasm/02b5939a:wasm-function[139]:0xaeab)
        at zend_user_it_get_new_iterator (wasm://wasm/02b5939a:wasm-function[8916]:0x5372d5)
        at ZEND_ADD_ARRAY_UNPACK_SPEC_HANDLER (wasm://wasm/02b5939a:wasm-function[13993]:0x6df9c1)
        at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
        at zend_execute (wasm://wasm/02b5939a:wasm-function[3335]:0x216beb)
        at zend_execute_scripts (wasm://wasm/02b5939a:wasm-function[9030]:0x540a71)
        at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
        ... 2 lines matching cause stack trace ...
        at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
        at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836) {
      cause: Error
          at Asyncify.handleSleep (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10749:45)
          at _wasm_poll_socket (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9627:21)
          at php_pollfd_for (wasm://wasm/02b5939a:wasm-function[967]:0x90aa8)
          at php_network_connect_socket (wasm://wasm/02b5939a:wasm-function[5415]:0x397c22)
          at php_tcp_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10486]:0x5a4e76)
          at php_openssl_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10621]:0x5b04ec)
          at _php_stream_set_option (wasm://wasm/02b5939a:wasm-function[487]:0x35fda)
          at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
          at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
          at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
          at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
          at _php_stream_xport_create (wasm://wasm/02b5939a:wasm-function[1712]:0xf1fa3)
          at zif_stream_socket_client (wasm://wasm/02b5939a:wasm-function[7893]:0x4b9abe)
          at ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02b5939a:wasm-function[13744]:0x6c0798)
          at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
          at zend_call_function (wasm://wasm/02b5939a:wasm-function[462]:0x32c3a)
    },
    betterMessage: '\n' +
      '"unreachable" WASM instruction executed.\n' +
      '\n' +
      'The typical reason is a PHP function missing from the ASYNCIFY_ONLY\n' +
      'list when building PHP.wasm.\n' +
      '\n' +
      'You will need to file a new issue in the WordPress Playground repository\n' +
      'and paste this error message there:\n' +
      '\n' +
      'https://github.com/WordPress/wordpress-playground/issues/new\n' +
      '\n' +
      "If you're a core developer, the typical fix is to:\n" +
      '\n' +
      '* Isolate a minimal reproduction of the error\n' +
      '* Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository\n' +
      "* Run 'npm run fix-asyncify'\n" +
      '* Commit the changes, push to the repo, release updated NPM packages\n' +
      '\n' +
      'Below is a list of all the PHP functions found in the stack trace to\n' +
      "help with the minimal reproduction. If they're all already listed in\n" +
      "the Dockerfile, you'll need to trigger this error again with long stack\n" +
      'traces enabled. In node.js, you can do it using the --stack-trace-limit=100\n' +
      'CLI option: \n' +
      '\n' +
      '    * php_pollfd_for\n' +
      '    * php_network_connect_socket\n' +
      '    * php_tcp_sockop_set_option\n' +
      '    * php_openssl_sockop_set_option\n' +
      '    * _php_stream_set_option\n' +
      '    * _php_stream_xport_create\n' +
      '    * zif_stream_socket_client\n' +
      '    * ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER\n' +
      '    * execute_ex\n' +
      '    * zend_call_function\n'
  }
}
Failed to start the server:
"unreachable" WASM instruction executed.

The typical reason is a PHP function missing from the ASYNCIFY_ONLY
list when building PHP.wasm.

You will need to file a new issue in the WordPress Playground repository
and paste this error message there:

https://github.com/WordPress/wordpress-playground/issues/new

If you're a core developer, the typical fix is to:

* Isolate a minimal reproduction of the error
* Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository
* Run 'npm run fix-asyncify'
* Commit the changes, push to the repo, release updated NPM packages

Below is a list of all the PHP functions found in the stack trace to
help with the minimal reproduction. If they're all already listed in
the Dockerfile, you'll need to trigger this error again with long stack
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
CLI option:

    * php_pollfd_for
    * php_network_connect_socket
    * php_tcp_sockop_set_option
    * php_openssl_sockop_set_option
    * _php_stream_set_option
    * _php_stream_xport_create
    * zif_stream_socket_client
    * ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER
    * execute_ex
    * zend_call_function



  WASM ERROR
  table index is out of bounds

wasm://wasm/02b5939a:1


RuntimeError: table index is out of bounds
    at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
    ... 2 lines matching cause stack trace ...
    at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
    at php_execute_script (wasm://wasm/02b5939a:wasm-function[10795]:0x5bf836)
    at dynCall_ii (wasm://wasm/02b5939a:wasm-function[12431]:0x65fa1a)
    at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
    at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
    at invoke_ii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10533:14)
    at wasm_sapi_handle_request (wasm://wasm/02b5939a:wasm-function[9415]:0x554538)
    at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
    at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
    at Object.doRewind (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9845:14)
    at /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9868:45
    at /Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9694:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error
      at Asyncify.handleSleep (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10749:45)
      at _wasm_poll_socket (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9627:21)
      at php_pollfd_for (wasm://wasm/02b5939a:wasm-function[967]:0x90aa8)
      at php_network_connect_socket (wasm://wasm/02b5939a:wasm-function[5415]:0x397c22)
      at php_tcp_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10486]:0x5a4e76)
      at php_openssl_sockop_set_option (wasm://wasm/02b5939a:wasm-function[10621]:0x5b04ec)
      at _php_stream_set_option (wasm://wasm/02b5939a:wasm-function[487]:0x35fda)
      at dynCall_iiiii (wasm://wasm/02b5939a:wasm-function[12428]:0x65f7b3)
      at ret.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:9762:33)
      at runtime.asm.<computed> (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:68056:18)
      at invoke_iiiii (/Users/remco/Projects/wp-pronamic-pay-with-mollie-for-gravity-forms/node_modules/@php-wasm/node/index.cjs:10610:14)
      at _php_stream_xport_create (wasm://wasm/02b5939a:wasm-function[1712]:0xf1fa3)
      at zif_stream_socket_client (wasm://wasm/02b5939a:wasm-function[7893]:0x4b9abe)
      at ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02b5939a:wasm-function[13744]:0x6c0798)
      at execute_ex (wasm://wasm/02b5939a:wasm-function[12242]:0x655c2f)
      at zend_call_function (wasm://wasm/02b5939a:wasm-function[462]:0x32c3a)
}

Node.js v21.6.2
@bgrgicak bgrgicak added this to the Zero Crashes milestone Mar 28, 2024
@bgrgicak bgrgicak added [Type] Bug An existing feature does not function as intended [Feature] PHP.wasm labels Mar 28, 2024
@adamziel
Copy link
Collaborator

Related: #273

@bgrgicak it would be nice to also test for generators and reaching for network resources between yields

@bgrgicak
Copy link
Collaborator

I can take a look at this one next week.

@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 2, 2024

I wasn't able to recreate the error using the above code, but this causes a similar issue:

	php.writeFile(
		joinPaths(docroot, 'test.php'),
		`<?php
			$data = new class() implements IteratorAggregate {
				public function getIterator(): Traversable {
					post_message_to_js( 'test' );
					return new ArrayIterator( [] );
				}
			};
			echo json_encode( [
				...$data
			] );
		`
	);

@adamziel
Copy link
Collaborator

adamziel commented Apr 2, 2024

@remcotolsma did that solve the problem for you? The latest version is now deployed to https://playground.wordpress.net/

@rvdsteege
Copy link

As a colleague of @remcotolsma, I followed along and it seems that the additions to ASYNCIFY_ONLY indeed resolve the issue with iterators. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] PHP.wasm [Type] Bug An existing feature does not function as intended
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants