I'm reporting this because I haven't found any other reports of code that worked previously, but now generates random Ruby segmentation fault errors after upgrading to the just-released Ruby 2.0.0-p0
.
I have a Sinatra application that generates a string that an .erb
template embeds in a data-
tag in the DOM. As I stated, this worked just fine until I upgraded to Ruby 2.0. With 2.0.0-p0
, It gives segmentation fault errors, usually after about 5 to 20 runs of the program. When I revert to Ruby 1.9, it works perfectly again and I can run the program hundreds of times without problems.
Here's an example of the results I get from these errors. This is the first few lines of the 'control frame information' section of the error listing:
-- Control frame information -----------------------------------------------
c:0061 p:0028 s:0315 e:000303 METHOD terrain_001.rb:509
c:0060 p:0012 s:0298 e:000296 BLOCK terrain_001.rb:494 [FINISH]
c:0059 p:---- s:0294 e:000293 CFUNC :each
c:0058 p:0008 s:0291 e:000290 BLOCK terrain_001.rb:493 [FINISH]
c:0057 p:---- s:0288 e:000287 CFUNC :each
c:0056 p:0023 s:0285 e:000284 METHOD terrain_001.rb:492
c:0055 p:0068 s:0281 e:000279 BLOCK /home/john/Desktop/stra-dams/views/index.erb:3 [FINISH]
The line numbers indicated as the location where the error occured are always in the following code, somewhere inside the definition for the hash values{}
after the encode
method has been called by the line str << encode(hex)
in the terrain_string
method:
def terrain_string
str = ""
@terrain = build_terrain
@terrain.each do |t|
t.each do |hex|
str << encode(hex)
end
end
str
end
# encode elevation values to a one-character code
def encode(elev)
values = {
:elev_10 => "a",
:elev_20 => "b",
:elev_30 => "c",
:elev_40 => "d",
:elev_50 => "e",
:elev_60 => "f",
:elev_70 => "g",
:elev_80 => "h",
Maybe after other people have tried the brand new Ruby 2.0 release, others will report similar errors. In the meantime, is there anything else I should be looking at that might help pinpoint the problem with the 2.0.0-p0
release?