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

spectest-interp: assert_malformed must error in reader alone #2252

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

keithw
Copy link
Member

@keithw keithw commented Jun 8, 2023

In the spectest interpreter, currently assert_malformed is treated the same as assert_invalid. This PR requires that assert_malformed modules must fail in the reader (not later in validation).

This also fixes an issue where assert_invalid wasn't validating text modules, so spectest-interp wasn't working properly for something like (assert_invalid (module quote "...") ""). There aren't a lot of tests like this because usually there's no need for (module quote) unless it's going to be in an (assert_malformed), but the memory64 tests have one because overlarge offsets are moving from a malformed failure to a validation failure. So this is a prerequisite for #2253.

This is logically dependent on #2251 (the tests won't pass until #2251 is merged).

@keithw keithw requested a review from sbc100 June 8, 2023 22:26
@keithw keithw force-pushed the spectest-invalid-fix-pr branch 2 times, most recently from 091d43e to 47625af Compare June 9, 2023 03:18
return Succeeded(
ValidateModule(&module, &errors, ValidateOptions{s_features}));
}

bool WellformedIR(const std::string& filename) {
return CheckIR(filename, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "well formed" something that exists in the spec, or something we a creating there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be the spec's term (e.g. "A byte sequence is a well-formed encoding of a module if and only if it is generated by the grammar." from 5.1). If you think it's better to match the script language, we could call these functions "InvalidIR" and "MalformedIR" (instead of "ValidIR" and "WellformedIR") and just negate the callsites?

wabt::Module module;
Errors errors;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this move of a line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Previously assert_malformed was treated the same as assert_invalid

Also fixes a bug where spectest-interp wasn't trying to validate
text modules (e.g. `(assert_invalid (module quote "...") "")`).
@keithw keithw enabled auto-merge (squash) June 11, 2023 23:49
@keithw keithw merged commit bd6ad17 into main Jun 12, 2023
@keithw keithw deleted the spectest-invalid-fix-pr branch June 12, 2023 00:07
@keithw keithw mentioned this pull request Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants