From: "Ara.T.Howard" Date: 2005-09-11T04:01:55+09:00 Subject: Re: Mmap crash when appending On Sun, 11 Sep 2005, Guillaume Marcais wrote: > [gus@hibernatus Bifurcation]$ cat mmap-abort.rb > require 'mmap' > mm = Mmap.new("test-mmap", "w") > 10.times { |i| p i; mm << "\0" * 1024 } > > [gus@hibernatus Bifurcation]$ > test-mmap > [gus@hibernatus Bifurcation]$ ruby mmap-abort.rb > 0 > 1 > 2 > 3 > 4 > mmap-abort.rb:3: [BUG] Bus Error > ruby 1.8.2 (2004-12-25) [i586-linux-gnu] > > Aborted > > [gus@hibernatus Bifurcation]$ ls -ls test-mmap > 4 -rw-rw-r-- 1 gus gus 4096 Sep 10 07:45 test-mmap > [gus@hibernatus Bifurcation]$ uname -a > Linux hibernatus.gus.marcais.net 2.6.11-6mdksmp #1 SMP Tue Mar 22 15:40:42 > CET 2005 i686 Pentium Pro unknown GNU/Linux > > The same behavior was showned on two different Linux machines (same > distribution though). > Any idea why it crashes? works fine for me: harp:~ > irb -r mmap -r fileutils irb(main):001:0> FileUtils::touch 'mmap' => ["mmap"] irb(main):002:0> mm = Mmap.new("mmap", "rw") => # irb(main):003:0> 1.times { |i| p i; mm << ("\0" * 1024) } 0 => 1 irb(main):004:0> 10.times { |i| p i; mm << ("\0" * 1024) } 0 1 2 3 4 5 6 7 8 9 => 10 irb(main):005:0> 20.times { |i| p i; mm << ("\0" * 1024) } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 => 20 irb(main):006:0> mm => # irb(main):007:0> mm.to_str.size => 31744 irb(main):008:0> mm.msync => # irb(main):009:0> IO::read('mmap').size => 31744 thoughts: - redhat has had many bugs with there mmap code. a short while ago i reported a simple c program that would hang the kernel https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124626 perhaps your linux version is buggy. if so bug the developers - mmap is such a fundemental operation (programs are always mmap'd when run by the kernel) that it's astounding that bugs like this get released. - did you install ruby via some package manager but compile the mmap dist? if you i'd (always) compile ruby vs. trusting the binary dists and compile mmap using this ruby, then see if the problem persists. other than that i can tell you i'm abusing mmap in the most sinister ways with no crashes or data corruption on a variety of linux dists. hth. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================