Actions
Bug #15346
closedCore dump during GC if covering a special require
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-11-27 trunk 66002) [x86_64-linux]
Backport:
Description
On my environment, (ruby-head, updated today) the following script generates a core dump almost all the time. (I join a core dump to this report)
I am running on Ubuntu 16.04, I first saw the problem on Travis-CI and managed to make this much simpler reproduction code.
# Just setting up a file to require, this could be in a regular file and be required.
require 'tempfile'
f = Tempfile.new(['ruby', '.rb'])
f.write(<<-RUBY)
a = 123
begin
ensure
a
end
RUBY
f.close
# Now the actual code to trigger the problem
require 'coverage'
Coverage.start
load f.path # require can do the same thing, but less frequently
# The problem is during GC, so we trigger it ourself
puts 'gc time!'
GC.start
# When it doesn't crash the first time, doing the load/require again seems to take care of it
puts '2nd gc'
load f.path
GC.start
puts 'gc done, try again!'
The problem seems related to the content of the ensure, if it's too simple, things break? It's weird.
If the content of the ensure is:
a
puts 'something'
#=> All good
puts 'something'
a
#=> Core dump
puts 'something'; a
#=> All good
a + 1
#=> All good
My personal guess is, if the last line of the ensure is useless, ruby optimizes it away, but that causes a problem with Coverage.
Files
Actions
Like0
Like0Like0Like0Like0Like0Like0