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

PHP: Process crash when intentionally triggering Asyncify error on 5.6, 7.2, 8.2 #354

Closed
adamziel opened this issue May 16, 2023 · 1 comment
Labels

Comments

@adamziel
Copy link
Collaborator

adamziel commented May 16, 2023

The test below crashes the process with Bus Error message on PHP 5.6, 7.2, and 8.2.

Asyncify errors are not meant to happen, but that crash will make debugging tedious when they do happen.

// @TODO Prevent crash on PHP versions 5.6, 7.2, 8.2
describe.each(['7.0','7.1','7.3','7.4','8.0','8.1'])('PHP %s – process crash', (phpVersion) => {
	let php: NodePHP;
	beforeEach(async () => {
		php = await NodePHP.load(phpVersion as any);
		php.setPhpIniEntry('allow_url_fopen', '1');
	});

	it('Does not crash due to an unhandled Asyncify error ', async () => {
		let caughtError;
		try {
			/**
			 * PHP is intentionally built without network support for __clone()
			 * because it's an extremely unlikely place for any network activity
			 * and not supporting it allows us to test the error handling here.
			 *
			 * `clone $x` will throw an asynchronous error out when attempting
			 * to do a network call ("unreachable" WASM instruction executed).
			 * This test should gracefully catch and handle that error.
			 *
			 * A failure to do so will crash the entire process
			 */
			await php.run({
				code: `<?php
				class Top {
					function __clone() {
						file_get_contents("http://127.0.0.1");
					}
				}
				$x = new Top();
				clone $x;
				`,
			});
		} catch (error) {
			caughtError = error;
			expect(error).toMatch(/Aborted|Program terminated with exit\(1\)|/);
		}
		if (!caughtError) {
			expect.fail('php.run should have thrown an error');
		}
	});
});
@adamziel
Copy link
Collaborator Author

adamziel commented Oct 9, 2024

Asyncify is now deprecated #134. Let's drop this stream of work and only do light maintenance of the Asyncify builds. Chrome and Firefox users are now on JSPI builds. Over time, Safari, other browsers, and the LTS Node.js release will start offering JSPI support and we'll be able to remove the Asyncify builds entirely.

@adamziel adamziel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant