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

Fix error handling in scanner in case of OOM #3793

Merged
merged 1 commit into from
May 27, 2020

Conversation

rerobika
Copy link
Member

This patch fixes #3786 and fixes #3788.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu

@dbatyai dbatyai added the bug Undesired behaviour label May 25, 2020
Copy link
Member

@dbatyai dbatyai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

I would like to understand what is happening here exactly.

jerry-core/parser/js/js-scanner.c Show resolved Hide resolved
jerry-core/parser/js/js-scanner.c Outdated Show resolved Hide resolved
jerry-core/parser/js/js-scanner.c Outdated Show resolved Hide resolved
@rerobika
Copy link
Member Author

The patch is updated. The related testcases in the issues cannot be added since there is no way to ensure that the OOM happens in the scanner not elsewhere in the engine.

@rerobika rerobika changed the title Fix error handling in scanner when in case of OOM Fix error handling in scanner in case of OOM May 26, 2020
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

Much better. Just a few things.

jerry-core/parser/js/js-scanner.c Show resolved Hide resolved
jerry-core/parser/js/js-scanner-util.c Outdated Show resolved Hide resolved
@rerobika
Copy link
Member Author

@zherczeg Thanks for the review, the PR is updated.

@zherczeg
Copy link
Member

I have been thinking about an alternative for this patch, which does not require a separate free function.

It would look like this:

PARSER_CATCH
{
  while (scanner_context.active_binding_list_p != NULL) ...

  if (JERRY_LIKELY (context_p->error != PARSER_ERR_OUT_OF_MEMORY))
  {
    context_p->error = PARSER_ERR_NO_ERROR;

    PARSER_TRY (context_p->try_buffer)
    {
      ...
    }
    PARSER_CATCH
    {
      JERRY_ASSERT (context_p->error == PARSER_ERR_OUT_OF_MEMORY);
    }
  }

  JERRY_ASSERT (context_p->error == PARSER_ERR_NO_ERROR || context_p->error == PARSER_ERR_OUT_OF_MEMORY);

  if (JERRY_UNLIKELY (context_p->error == PARSER_ERR_OUT_OF_MEMORY))
  {
      release...
      parser_stack_free (context_p);
      return;
  }
}

What do you think? I can do it in a separate patch if you wish.

@rerobika
Copy link
Member Author

+1 for the separate patch!

This patch fixes jerryscript-project#3786 and fixes jerryscript-project#3788.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
@rerobika
Copy link
Member Author

@zherczeg I've updated the PR with the suggested code above.

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

LGTM
Much better!

@rerobika rerobika merged commit 69f8e78 into jerryscript-project:master May 27, 2020
@rerobika rerobika deleted the fix_issue_3786_3788 branch June 16, 2020 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour
Projects
None yet
3 participants