Project

General

Profile

Actions

Bug #13305

closed

Occasional segfaults after defining methods while running coverage

Added by decuplet (Nikita Shilnikov) over 7 years ago. Updated almost 7 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16], ruby 2.5.0dev (2017-03-13 trunk 57944) [x86_64-darwin16]
[ruby-core:80079]

Description

The problem occurs on MRI 2.4.0 and the latest trunk only (2017-03-13 trunk 57944). After running Coverage.start code defines the same method few times but every time the size of the method increases. Occasionally MRI can fail on attempt to get the coverage result. The bug can be reproduced quite easily with the following two files

a.rb

require 'coverage'
Coverage.start

require_relative './b'

add_method(Class.new)

Coverage.result

b.rb

REPEATS = 400

def add_method(target)
  REPEATS.times do
    target.class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
      def foo
        #{"\n" * rand(REPEATS)}
      end
      1
    RUBY
  end
end

Run ruby a.rb to reproduce the bug. Several runs may be required before MRI fails, but for me it fails on almost every run.

Note that passing filename and line number to class_eval is important, so as adding 1 after the method definition.

The crash report attached to the issue.


Files


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #13594: Segfault in gc_sweep_step 2.4.1ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0