-
Notifications
You must be signed in to change notification settings - Fork 486
Open
Description
Steps to reproduce
- Use Ruby 3.4.x, Rails 8.1.x, view_component 4.2.0
- Enable code coverage with SimpleCov (or any coverage tool)
- Run bin/rails test
The segfault occurs during component compilation when class_eval is called with a negative line number (-1).
Root cause: In v4.2.0, Template::File#initialize sets lineno = -1 for Rails 8.1+ with ERB handler:
# lib/view_component/template.rb lines 26-31
lineno =
if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR > 0 && details.handler == :erb
- 1
else
0
end
This is then passed to class_eval at line 119:
@component.class_eval <<~RUBY, @path, @lineno
When Ruby's coverage is enabled, negative line numbers in eval/class_eval trigger a segmentation fault. This is documented in https://bugs.ruby-lang.org/issues/19363.
Expected behavior
Tests run without crashing.
Actual behavior
Segmentation fault during eager loading/component compilation.
Backtrace:
/vendor/bundle/ruby/3.4.0/gems/view_component-4.2.0/lib/view_component/template.rb:119: [BUG] Segmentation fault at 0x0000000000000024
ruby 3.4.8 (2025-12-17 revision 995b59f666) +PRISM [x86_64-linux]
System configuration
Rails version: 8.1.2
Ruby version: 3.4.8
Gem version: 4.2.0
This works on 4.1.1 which always uses lineno: 0.
dereke and MykolaYankovskyy
Metadata
Metadata
Assignees
Labels
No labels