Project

General

Profile

Actions

Bug #19587

closed

Segmentation fault with ruby 3.2.0 - when running rspec suit.

Added by rubanthilak (Ruban Thilak) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:113165]

Description

The segmentation fault occurs when this particular regex match happens while running the entire Rspec test suit.

    it 'returns nil after timeout for untrusted regex' do
      extracted_value = described_class.extract('test1-test2-test3-test4-test_5', '^([0-9a-zA-Z\-/]*){1,256}$')
      expect(extracted_value).to be_nil
    end

But when I try to run only that particular spec file, segmentation fault does not occur.

/runner/_work/Event_Mgmt_Service/Event_Mgmt_Service/lib/regex/parser.rb:17: [BUG] Segmentation fault at 0x0000706c4c1ada0c
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0048 p:---- s:0243 e:000242 CFUNC  :match?
c:0047 p:0016 s:0238 e:000237 METHOD /runner/_work/.../lib/regex/parser.rb:17
c:0046 p:0009 s:0230 e:000229 BLOCK  /runner/_work/.../spec/lib/regex/parser_spec.rb:22 [FINISH]
c:0045 p:---- s:0226 e:000225 CFUNC  :instance_exec
c:0044 p:0022 s:0221 e:000220 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:263
c:0043 p:0002 s:0216 e:000215 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:511
c:0042 p:0002 s:0213 e:000212 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:468
c:0041 p:0002 s:0210 e:000209 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:486
c:0040 p:0002 s:0207 e:000206 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:626
c:0039 p:0018 s:0204 e:000203 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:352
c:0038 p:0008 s:0198 e:000197 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-rails-4.1.2/lib/rspec/rails/adapters.rb:75 [FINISH]
c:0037 p:---- s:0194 e:000193 CFUNC  :instance_exec
c:0036 p:0013 s:0189 e:000188 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:457
c:0035 p:0010 s:0183 e:000182 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:390
c:0034 p:0009 s:0177 e:000176 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:628
c:0033 p:0018 s:0174 e:000173 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:352
c:0032 p:0004 s:0168 e:000167 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/webmock-3.18.1/lib/webmock/rspec.rb:37 [FINISH]
c:0031 p:---- s:0164 e:000163 CFUNC  :instance_exec
c:0030 p:0013 s:0159 e:000158 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:457
c:0029 p:0010 s:0153 e:000152 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:390
c:0028 p:0009 s:0147 e:000146 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:628
c:0027 p:0018 s:0144 e:000143 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:352
c:0026 p:0037 s:0138 E:0024f8 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:629
c:0025 p:0104 s:0131 E:002588 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:486
c:0024 p:0018 s:0124 E:0009c8 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:468
c:0023 p:0019 s:0119 E:000a58 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:511
c:0022 p:0076 s:0114 E:000768 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example.rb:259
c:0021 p:0037 s:0107 e:000106 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example_group.rb:646 [FINISH]
c:0020 p:---- s:0101 e:000100 CFUNC  :map
c:0019 p:0011 s:0097 e:000096 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example_group.rb:642
c:0018 p:0052 s:0092 e:000091 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example_group.rb:607
c:0017 p:0006 s:0083 e:000082 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example_group.rb:608 [FINISH]
c:0016 p:---- s:0079 e:000078 CFUNC  :map
c:0015 p:0065 s:0075 e:000074 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/example_group.rb:608
c:0014 p:0007 s:0066 e:000065 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:121 [FINISH]
c:0013 p:---- s:0062 e:000061 CFUNC  :map
c:0012 p:0030 s:0058 e:000057 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:121
c:0011 p:0026 s:0055 e:000054 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/configuration.rb:2070
c:0010 p:0007 s:0051 e:000050 BLOCK  /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:116
c:0009 p:0009 s:0047 e:000046 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/reporter.rb:74
c:0008 p:0019 s:0042 e:000041 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:115
c:0007 p:0035 s:0035 e:000034 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:89
c:0006 p:0058 s:0029 e:000028 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:71
c:0005 p:0013 s:0021 e:000020 METHOD /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/lib/rspec/core/runner.rb:45
c:0004 p:0010 s:0016 e:000015 TOP    /opt/hostedtoolcache/Ruby/3.2.0/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.12.1/exe/rspec:4 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC  :load
c:0002 p:0078 s:0008 E:0025f0 EVAL   /opt/hostedtoolcache/Ruby/3.2.0/x64/bin/rspec:25 [FINISH]
c:0001 p:0000 s:0003 E:0018a0 DUMMY  [FINISH]

Updated by rubanthilak (Ruban Thilak) over 1 year ago

Rails Version : 6-1-stable
Bundler Version: 2.4.1
rspec-rails Version: 4.0

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

What does described_class.extract actually?

Updated by rubanthilak (Ruban Thilak) over 1 year ago

This is the described_class.

module Regex
  module Parser
    extend self
  
    def extract(str, regex_str)
      regex = Regexp.new(regex_str, timeout: 1.0)
      regex.match?(str) ? str.match(regex) : nil
    rescue => e
      nil
    end
  end
end

Actions #5

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED
Actions #6

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|0ac3f2c20e50c22d298238f602f25f84248ac7a5.


[Bug #19587] Fix reset_match_cache arguments

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

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

ruby_3_2 a7b0d3c9db9afeccf6e0962bb1cdcbea5bf04cae merged revision(s) 0ac3f2c20e50c22d298238f602f25f84248ac7a5.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0