Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fixing handling of stack overflows. #2553

Closed
wants to merge 2 commits into from
Closed

Fixing handling of stack overflows. #2553

wants to merge 2 commits into from

Conversation

NTillmann
Copy link
Contributor

Release notes: User-level stack overflows no longer crash Prepack.

This fixes #2552, and actually a bit more:

  • We used to piggy-back on pushContext to count stack frames. However, there is no one-to-one correspondance of calls and context, so that wasn't a very good proxy. (In fact, there seem to be calls that don't push a context.) So we now count calls and constructs explicitly.
  • Instead of just throwing a FatalError when the stack space is exceeded, which in turn causes an invariant violation since there must not be a FatalError thrown without a compiler diagnostics having beein issue. Now there is a regular error code PP0045.

Added error handler regression test.

Release notes: User-level stack overflows no longer crash Prepack.

This fixes #2552, and actually a bit more:
- We used to piggy-back on `pushContext` to count stack frames. However, there is no one-to-one correspondance of calls and context, so that wasn't a very good proxy. (In fact, there seem to be calls that don't push a context.) So we now count calls and constructs explicitly.
- Instead of just throwing a `FatalError` when the stack space is exceeded, which in turn causes an invariant violation since there must not be a `FatalError` thrown without a compiler diagnostics having beein issue. Now there is a regular error code PP0045.

Added error handler regression test.
@@ -258,7 +258,7 @@ export class Realm {

this.start = Date.now();
this.compatibility = opts.compatibility !== undefined ? opts.compatibility : "browser";
this.maxStackDepth = opts.maxStackDepth || 225;
this.remainingCalls = opts.maxStackDepth || 112;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to reduce default maximum a bit to ensure that we don't run out of default node.js space before running out of default Prepack stack space.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

NTillmann is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trivial program crashes Prepack
3 participants