Project

General

Profile

Actions

Bug #20475

closed

RJIT `and' NoMatchingPatternError

Added by ukolovda (Dmitry Ukolov) about 2 months ago. Updated about 2 months ago.

Status:
Feedback
Target version:
-
ruby -v:
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]
[ruby-core:117796]

Description

I try use RJIT for testing of Rails application:

$ RUBYOPT="--rjit" bin/bundle exec rake test
Started with run options --seed 63595
...
/home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/assembler.rb:124:in `and': [:rax, [:rbx, 128]] (NoMatchingPatternError)                                                  ] 70% Time: 00:05:26,  ETA: 00:02:19
        from /home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/insn_compiler.rb:2348:in `opt_and'
        from /home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/insn_compiler.rb:118:in `compile'
        from /home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/compiler.rb:321:in `compile_block'
        from /home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/compiler.rb:150:in `block in branch_stub_hit'
        from <internal:kernel>:133:in `then'
        from /home/ukolovda/.rvm/rubies/ruby-3.3.1/lib/ruby/3.3.0/ruby_vm/rjit/compiler.rb:149:in `branch_stub_hit'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/spreadsheet-1.3.1/lib/spreadsheet/excel/reader.rb:1263:in `set_row_address'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/spreadsheet-1.3.1/lib/spreadsheet/excel/reader.rb:884:in `read_worksheet'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/spreadsheet-1.3.1/lib/spreadsheet/excel/worksheet.rb:53:in `ensure_rows_read'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/spreadsheet-1.3.1/lib/spreadsheet/excel/worksheet.rb:46:in `each'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/bundler/gems/roo-xls-0032c662b4ad/lib/roo/xls/excel.rb:253:in `read_cells'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/roo-2.10.1/lib/roo/base.rb:119:in `block (2 levels) in <class:Base>'
        from /home/ukolovda/RubymineProjects/cc/app/app/models/concerns/contact_import.rb:401:in `open_spreadsheet'
        from /home/ukolovda/RubymineProjects/cc/app/app/models/concerns/contact_import.rb:317:in `parse_contacts'
        from /home/ukolovda/RubymineProjects/cc/app/app/models/concerns/contact_import.rb:206:in `import_contacts'
        from /home/ukolovda/RubymineProjects/cc/app/test/models/contact_test.rb:23:in `do_import2'
        from /home/ukolovda/RubymineProjects/cc/app/test/models/contact_test.rb:18:in `do_import'
        from /home/ukolovda/RubymineProjects/cc/app/test/models/contact_test.rb:194:in `block in <class:ContactTest>'
        from /home/ukolovda/RubymineProjects/cc/app/test/models/contact_test.rb:201:in `instance_exec'
        from /home/ukolovda/RubymineProjects/cc/app/test/models/contact_test.rb:201:in `block in create_test_from_should_hash'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:95:in `block (3 levels) in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:192:in `capture_exceptions'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:90:in `block (2 levels) in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:324:in `time_it'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:89:in `block in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:423:in `on_signal'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:240:in `with_info_handler'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest/test.rb:88:in `run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-reporters-1.6.1/lib/minitest/reporters.rb:48:in `run_with_hooks'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/activesupport-7.1.3.2/lib/active_support/executor/test_helper.rb:5:in `block in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/activesupport-7.1.3.2/lib/active_support/execution_wrapper.rb:105:in `perform'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/activesupport-7.1.3.2/lib/active_support/executor/test_helper.rb:5:in `run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:1138:in `run_one_method'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:389:in `run_one_method'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:376:in `block (2 levels) in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:375:in `each'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:375:in `block in run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:423:in `on_signal'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:410:in `with_info_handler'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:374:in `run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/railties-7.1.3.2/lib/rails/test_unit/line_filtering.rb:10:in `run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:206:in `block in __run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:206:in `map'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:206:in `__run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:162:in `run'
        from /home/ukolovda/.rvm/gems/ruby-3.3.1/gems/minitest-5.22.3/lib/minitest.rb:86:in `block in autorun'

I cannot give entire application, but this error happen on line
https://github.com/zdavatz/spreadsheet/blob/2f4253f2eb882fd4d43eaed164eb8a1141cec0ef/lib/spreadsheet/excel/reader.rb#L1263
of spreadsheet gem.

I try reproduce error on this gem with --rjit option, but can't.

I also try extract calculation of boolean to variable, and it work fine, but error happen later:
Origin code (spreadsheet-1.3.1/lib/spreadsheet/excel/reader.rb, line from 1255):

    attrs = {
      :default_format => format,
      :first_used     => first_used,
      :first_unused   => first_unused,
      :index          => index,
      :row_block      => @current_row_block_offset,
      :offset         => @current_row_block_offset[0],
      :outline_level  => flags & 0x00000007,
      :collapsed      => (flags & 0x0000010) > 0, # <== Error happen there
      :hidden         => (flags & 0x0000020) > 0,
    }

Modified code:

    collapsed = (flags & 0x0000010) > 0
    hidden = (flags & 0x0000020) > 0
    outline_level  = flags & 0x00000007
    # TODO: read attributes from work[13,3], read flags
    attrs = {
      :default_format => format,
      :first_used     => first_used,
      :first_unused   => first_unused,
      :index          => index,
      :row_block      => @current_row_block_offset,
      :offset         => @current_row_block_offset[0],
      :outline_level  => outline_level,
      :collapsed      => collapsed,
      :hidden         => hidden,
    }
    if (flags & 0x00000040) > 0 # <== Error happen there
      attrs.store :height, height / TWIPS
    end

And new error have other attribute:
ruby_vm/rjit/assembler.rb:124:in `and': [:rax, [:rbx, -136]] (NoMatchingPatternError)


Related issues 1 (0 open1 closed)

Copied to Ruby master - Bug #20477: RJIT NoMatchingPatternError when initialize Hash literal with more 8 itemsFeedbackk0kubun (Takashi Kokubun)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0