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

src: handle fatal error when Environment is not assigned to context #27236

Closed
wants to merge 2 commits into from

Commits on Apr 15, 2019

  1. src: handle fatal error when Environment is not assigned to context

    Previously when a uncaught JS error is thrown before Environment was
    assigned to the context (e.g. a SyntaxError in a per-context script),
    it triggered an infinite recursion:
    
    1. The error message listener `node::OnMessage()` triggered
       `node::FatalException()`
    2. `node::FatalException()` attempted to get the Environment
       assigned to the context entered using `Environment::GetCurrent()`
    3. `Environment::GetCurrent()` previously incorrectly accepted
       out-of-bound access with the length of the embedder data array
       as index, and called `context->GetAlignedPointerFromEmbedderData()`
    4. The out-of-bound access in `GetAlignedPointerFromEmbedderData()`
       triggered a fatal error, which was handled by `node::FatalError()`
    5. `node::FatalError()` calls `node::FatalException()`, then
       we enter the infinite recursion.
    
    This patch fixes the incorrect guard in 3, and handles error with
    best-effort when `Environment::GetCurrent()` returns nullptr
    (when Environment is not yet assigned to the context) in 2.
    joyeecheung committed Apr 15, 2019
    Configuration menu
    Copy the full SHA
    cee0872 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7933801 View commit details
    Browse the repository at this point in the history