Project

General

Profile

Actions

Bug #19750

closed

Ruby hangs when parsing Regexp with unterminated unicode "/\u{"

Added by tompng (tomoya ishida) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
[ruby-core:114049]

Description

Ruby hangs up for a while and gets failed to allocate memory (NoMemoryError)

$ ruby -e "/\\u{"
ruby: failed to allocate memory (NoMemoryError)
RubyVM::AbstractSyntaxTree.parse "/\\u{"
# => SyntaxError

RubyVM::AbstractSyntaxTree.parse "/\\u{\n"
# => failed to allocate memory (NoMemoryError)

Found in https://github.com/ruby/irb/issues/620


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #18294: error when parsing regexp commentClosedActions
Actions #1

Updated by mame (Yusuke Endoh) over 1 year ago

  • Related to Bug #18294: error when parsing regexp comment added

Updated by mame (Yusuke Endoh) over 1 year ago

  • Status changed from Open to Assigned
  • Assignee set to jeremyevans0 (Jeremy Evans)

According to git bisect, this is since ec3542229b29ec93062e9d90e877ea29d3c19472. @jeremyevans0 (Jeremy Evans) Could you take a look at this issue?

Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

mame (Yusuke Endoh) wrote in #note-2:

According to git bisect, this is since ec3542229b29ec93062e9d90e877ea29d3c19472. @jeremyevans0 (Jeremy Evans) Could you take a look at this issue?

Sure, I'll take a look today.

Actions #5

Updated by jeremyevans (Jeremy Evans) over 1 year ago

  • Status changed from Assigned to Closed

Applied in changeset git|1bc8838d60ef3fc6812d3b64ed87caaf0ae943d9.


Handle unterminated unicode escapes in regexps

This fixes an infinite loop possible after ec3542229b29ec93062e9d90e877ea29d3c19472.
For \u{} escapes in regexps, skip validation in the parser, and rely on the regexp
code to handle validation. This is necessary so that invalid unicode escapes in
comments in extended regexps are allowed.

Fixes [Bug #19750]

Co-authored-by: Nobuyoshi Nakada

Actions #6

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: REQUIRED to 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: DONE

ruby_3_2 3f6187a94797d3c4a7db00563a885e4e613b51cf merged revision(s) 1bc8838d60ef3fc6812d3b64ed87caaf0ae943d9.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0