-
Notifications
You must be signed in to change notification settings - Fork 340
Closed as not planned
Closed as not planned
Copy link
Labels
[Feature] PHP.wasm[Priority] Low[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] Developer Experience
Description
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');
}
});
});
Metadata
Metadata
Assignees
Labels
[Feature] PHP.wasm[Priority] Low[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] Developer Experience