Skip to content

Support empty quoted modules with annotations - #2865

Open
zherczeg wants to merge 1 commit into
WebAssembly:mainfrom
zherczeg:empty_annot
Open

zherczeg wants to merge 1 commit into
WebAssembly:mainfrom
zherczeg:empty_annot

Conversation

@zherczeg

Copy link
Copy Markdown
Collaborator

No description provided.

@zherczeg

Copy link
Copy Markdown
Collaborator Author

This change allows running the following tests:
https://github.com/WebAssembly/testsuite/blob/main/annotations.wast#L32

This change does not change the handling of empty modules in the library.

Comment thread src/wast-parser.cc
Comment on lines +3936 to +3937
if (errors.size() == 1 && errors[0].error_level == ErrorLevel::Warning &&
errors[0].message == "empty module") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems a little hacky to generate the warning and then remove it. Is this worth the benefit? I.e. do we have such modules in the wild that we want to support without warnings?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What do you suggest instead?
This affect spec tests (Quoted modules) only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there some way we could simple not generate the "empty module" warning at all in the case that annotation is present? I assume that is not simple otherwise you would have done it already?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. The next token functions silently consumes the unknown annotations. Adding a bool which is set if an annotation is encountered seems the easiest solution, but this is a warning, and probably useful in the general case. Warnings converted to errors by the spec test executor for some reason. We could also ignore warnings though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the empty module warning does seem reasonable, so maybe finding a way to suppress it in the spec runner is the best way to do. Presumably its OK if the spec tests contain warnings?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What are the purpose of warnings btw? We only have 3 types of warnings at the moment: empty module, empty script, and custom section reading error in binary reader.

As for me warnings represent those cases, which are valid according to the specification, but still useful to tell the user a possible issue. From this perspective, spec tests might contain warnings, and they are still valid.

To reduce human error, I would only suppress as few warnings as possible. Contents of the spec tests should be ok, but we might make errors when processing them. Warnings could help to reveal that.

This branch has not been deployed

No deployments
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