Skip to content

Limit interpreter depth in precompute, but not when running whole modules#2191

Merged
kripken merged 6 commits intomasterfrom
a5
Jul 2, 2019
Merged

Limit interpreter depth in precompute, but not when running whole modules#2191
kripken merged 6 commits intomasterfrom
a5

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Jun 30, 2019

Keep limiting in precompute as before: that is useful since that pass is run as part of normal compilation, and we want to avoid native stack limits on all platforms. Also that pass is not likely to find any pattern of size 50 of higher that it can't precompute as a sum of smaller pieces.

Restore the 250 limit from before for interpreting entire modules, as without that the fuzzer will sometimes hit the limit and cause a false positive.

@kripken kripken requested a review from tlively June 30, 2019 15:44
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

LGTM with a nit and a question.

Comment thread src/wasm-interpreter.h
// Keep a record of call depth, to guard against excessive recursion.
size_t depth = 0;
Index maxDepth;

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.

nit: this whitespace looks unnecessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's sort of separating the input values from the internal state values. Is there a clearer way to do that? I could use another protected: block lower down I guess.

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.

Nope, this newline seems fine if it's there intentionally 👍

Comment thread src/passes/Precompute.cpp Outdated
// that we can do anything useful to precompute a hugely nested expression
// (we should succed at smaller parts of it first). Second, a low limit is
// helpful to avoid platform differences in native stack sizes.
enum { MAX_DEPTH = 50 };
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.

Why use an enum here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It could be a static const or a #define I guess. I don't have a preference, what do you think?

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 would default to using a static const. That way the underlying type is clear and there are no extra type shenanigans happening.

@kripken kripken merged commit c3e45d4 into master Jul 2, 2019
@kripken kripken deleted the a5 branch July 2, 2019 02:22
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