Skip to content

Instantly share code, notes, and snippets.

@copiousfreetime
Last active August 29, 2015 14:05
Show Gist options
  • Save copiousfreetime/46ce78f08885b24bc8dd to your computer and use it in GitHub Desktop.
Save copiousfreetime/46ce78f08885b24bc8dd to your computer and use it in GitHub Desktop.
Segmentation fault with Containers::RBTreeMap
require 'benchmark'
#require 'rbtree'
require 'algorithms'
Benchmark.bm(20) do |r|
data = nil
r.report('shuffling') { data = (0..1_000_000).to_a.shuffle }
{ :hash => Hash.new,
# :classic => RBTree.new,
:container => Containers::RBTreeMap.new }.each do |kind,tree|
r.report( "write #{kind}" ) { data.each { |d| tree[d] = "foo" } }
r.report( "read #{kind}" ) { data.each { |d| tree[d] } }
if kind == :container then
r.report( "drain #{kind}" ) { tree.delete_min until tree.empty? }
else
r.report( "drain #{kind}" ) { tree.shift until tree.empty? }
end
end
end
user system total real
shuffling 0.090000 0.010000 0.100000 ( 0.092279)
write hash 0.850000 0.050000 0.900000 ( 0.919895)
read hash 0.420000 0.010000 0.430000 ( 0.419167)
drain hash 0.570000 0.020000 0.590000 ( 0.599493)
write container bench_rbtree.rb:16: [BUG] Segmentation fault at 0x007fff584bcfe4
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin12.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
c:0013 p:---- s:0061 e:000060 CFUNC :push
c:0012 p:0016 s:0056 e:000054 BLOCK bench_rbtree.rb:16 [FINISH]
c:0011 p:---- s:0052 e:000051 CFUNC :each
c:0010 p:0009 s:0049 e:000048 BLOCK bench_rbtree.rb:16
c:0009 p:0034 s:0047 e:000046 METHOD /opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:279
c:0008 p:0039 s:0039 e:000037 METHOD /opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:361
c:0007 p:0015 s:0031 E:000a58 BLOCK bench_rbtree.rb:16 [FINISH]
c:0006 p:---- s:0027 e:000026 CFUNC :each
c:0005 p:0050 s:0024 E:001e58 BLOCK bench_rbtree.rb:14
c:0004 p:0133 s:0020 e:000019 METHOD /opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:172
c:0003 p:0030 s:0010 e:000009 METHOD /opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:204
c:0002 p:0029 s:0004 E:0010a8 EVAL bench_rbtree.rb:5 [FINISH]
c:0001 p:0000 s:0002 E:000cf8 TOP [FINISH]
bench_rbtree.rb:5:in `<main>'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:204:in `bm'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:172:in `benchmark'
bench_rbtree.rb:14:in `block in <main>'
bench_rbtree.rb:14:in `each'
bench_rbtree.rb:16:in `block (2 levels) in <main>'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:361:in `item'
/opt/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
bench_rbtree.rb:16:in `block (3 levels) in <main>'
bench_rbtree.rb:16:in `each'
bench_rbtree.rb:16:in `block (4 levels) in <main>'
bench_rbtree.rb:16:in `push'
-- C level backtrace information -------------------------------------------
Segmentation fault: 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment