Skip to content

Instantly share code, notes, and snippets.

@thbar
Created February 1, 2011 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thbar/806234 to your computer and use it in GitHub Desktop.
Save thbar/806234 to your computer and use it in GitHub Desktop.
A non-portable, "non-blocking on crash" repro for the segfault hpricot issue
#!/usr/bin/env ruby
require 'test/unit'
require 'hpricot'
require 'load_files'
require 'neversaydie'
class TestSegFaults < Test::Unit::TestCase
def test_segfault
read, write = IO.pipe
Process.fork do
15.times do |i|
data = "<item>"
50000.times do |j|
data << "<line>This is line #{j} for turn #{i}</line>"
end
data << "</item>"
# generates a segfault on Hpricot 0.8.3
doc = Hpricot(data)
end
write.puts "OK"
end
sleep(5)
write.close
assert_match read.read, /OK/, "Hpricot crashed!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment