Searching for a non-existing string in a mmapped region produces a segfault.
Run the following little program:
require 'mmap’
file = “/usr/bin/ruby"
fma = Mmap.new(file, “r”, Mmap::MAP_SHARED, {‘offset’ => 8192, ‘length’ => 4096})
puts fma.index(”\n#\n", 12)
fma.unmap
Under 1.8.0:
tt.rb:10: [BUG] Segmentation fault
ruby 1.8.0 (2003-08-04) [i686-linux]
Aborted
With 1.6.8:
nil
Cheers,
Han Holl
ts1
(ts)
2
Searching for a non-existing string in a mmapped region produces a
segfault.
bug in ruby :-))
re.c (line 142)
while (s < e) {
if (hx == hy && memcmp(x, s, m) == 0) {
return s-y;
}
hy = KR_REHASH(*s, *(s+d), hy);
s++;
}
s+d can be > e
illegal access which give with a mapped file a segfault, with a normal
string it can work
Guy Decoux
nobu.nokada@softhome.net wrote in message
[ patch cut ]
Many thanks to you and Guy for the speedy reply.
Works fine now.
Cheers,
Han Holl