From: Mark Hubbart Date: 2004-05-25T01:34:30+09:00 Subject: Re: compiling mmap? On May 24, 2004, at 9:15 AM, ts wrote: >>>>>> "M" == Mark Hubbart writes: > > M> test_13_div(TestMmap) [mmapt.rb:304]: > M> empty. > M> expected but was > M> . > > Well, it's normal : the test is not adapted with "rw" it will not > truncate > the file. This is not the good correction, try with > > svg% diff -u mmap.c~ mmap.c > --- mmap.c~ 2004-05-24 11:20:04.000000000 +0200 > +++ mmap.c 2004-05-24 18:13:45.000000000 +0200 > @@ -420,10 +420,7 @@ > } > else if (strcmp(mode, "w") == 0) { > smode = O_RDWR | O_TRUNC; > - pmode = PROT_WRITE; > - if (!NIL_P(fdv)) { > - pmode |= PROT_READ; > - } > + pmode = PROT_READ | PROT_WRITE; > } > else if (strcmp(mode, "rw") == 0 || strcmp(mode, "wr") == 0) { > smode = O_RDWR; > svg% > > and in tests/mmapt.rb reverse the modification > > assert_kind_of(Mmap, m1 = Mmap.new("tmp/bb", "w"), "new a") well, patch failed, are you working with a cvs version? anyway, I made the change by hand, and I got a bus error: (gdb) run -d tests/mmapt.rb Starting program: /usr/local/bin/ruby -d tests/mmapt.rb Reading symbols for shared libraries +... done tests/mmapt.rb:2: warning: `*' interpreted as argument prefix Reading symbols for shared libraries . done Loaded suite tests/mmapt Started ............. Program received signal EXC_BAD_ACCESS, Could not access memory. 0xffff87b8 in __memcpy () (gdb) bt #0 0xffff87b8 in __memcpy () #1 0x0004dc6c in mm_cat (str=1760744, ptr=0x62edf0 "azertyuiopqsdfghjklm", len=20) at mmap.c:1100 #2 0x0004dcd0 in mm_append (str1=1760744, str2=1761584) at mmap.c:1112 #3 0x0004dd24 in mm_concat (str1=970752, str2=6483440) at mmap.c:1127 #4 0x00202370 in rb_call0 (klass=105488, recv=1760744, id=334, oid=334, argc=1, argv=0xbffda490, body=0x19080, nosuper=0) at eval.c:5479 #5 0x00202ca4 in rb_call (klass=105488, recv=334, mid=3221069616, argc=1, argv=0xbffda490, scope=2708276) at eval.c:5696 #6 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #7 0x001fd288 in rb_eval (self=0, n=0x62edf0) at eval.c:3233 #8 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=3221070996, argc=-1072431104, argv=0x0, body=0xbffdd3e0, nosuper=0) at eval.c:5603 #9 0x00202ca4 in rb_call (klass=520656, recv=3221070996, mid=3221070960, argc=1760744, argv=0x1, scope=0) at eval.c:5696 #10 0x00202ed0 in rb_f_send (argc=0, argv=0xbffdd9b4, recv=490336) at ruby.h:634 #11 0x00202370 in rb_call0 (klass=232608, recv=490336, id=3905, oid=490336, argc=1, argv=0xbffdd9b0, body=0x36d60, nosuper=0) at eval.c:5479 #12 0x00202ca4 in rb_call (klass=232608, recv=490336, mid=3221084596, argc=491816, argv=0x2a2dc8, scope=520656) at eval.c:5696 #13 0x001fd434 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #14 0x001fc850 in rb_eval (self=490336, n=0x62edf0) at eval.c:3054 #15 0x001fc99c in rb_eval (self=490336, n=0x62edf0) at eval.c:3079 #16 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=3221084596, argc=-1072431104, argv=0x0, body=0xbffe1cf0, nosuper=0) at eval.c:5603 #17 0x00202ca4 in rb_call (klass=688776, recv=3221084596, mid=3221084560, argc=1, argv=0xbffdd9b0, scope=0) at eval.c:5696 #18 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #19 0x00208434 in block_pass (self=491556, node=0xa93e0) at eval.c:8357 #20 0x001fc194 in rb_eval (self=491556, n=0x62edf0) at eval.c:2929 #21 0x00200724 in rb_yield_0 (val=490336, self=491556, klass=0, flags=-1073858896, avalue=0) at eval.c:4687 #22 0x001e6464 in rb_ary_each (ary=3221113792) at array.c:1155 #23 0x00202370 in rb_call0 (klass=204848, recv=490916, id=3849, oid=0, argc=0, argv=0x0, body=0x31c0c, nosuper=0) at eval.c:5479 #24 0x00202ca4 in rb_call (klass=204848, recv=0, mid=3221108400, argc=0, argv=0x0, scope=-1073853504) at eval.c:5696 #25 0x001fd1d0 in rb_eval (self=491556, n=0x62edf0) at ruby.h:634 #26 0x001fc350 in rb_eval (self=491556, n=0x62edf0) at eval.c:2943 #27 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=0, argc=-1072431104, argv=0x0, body=0xbffe8760, nosuper=0) at eval.c:5603 #28 0x00202ca4 in rb_call (klass=689956, recv=0, mid=3221117104, argc=490916, argv=0x0, scope=2708280) at eval.c:5696 #29 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #30 0x00208434 in block_pass (self=493516, node=0xa93e0) at eval.c:8357 #31 0x001fc194 in rb_eval (self=493516, n=0x62edf0) at eval.c:2929 #32 0x00200724 in rb_yield_0 (val=491556, self=493516, klass=0, flags=-1073831648, avalue=0) at eval.c:4687 #33 0x001e6464 in rb_ary_each (ary=3221141040) at array.c:1155 #34 0x00202370 in rb_call0 (klass=204848, recv=493476, id=3849, oid=0, argc=0, argv=0x0, body=0x31c0c, nosuper=0) at eval.c:5479 #35 0x00202ca4 in rb_call (klass=204848, recv=0, mid=3221135648, argc=0, argv=0x0, scope=-1073826256) at eval.c:5696 #36 0x001fd1d0 in rb_eval (self=493516, n=0x62edf0) at ruby.h:634 #37 0x001fc350 in rb_eval (self=493516, n=0x62edf0) at eval.c:2943 #38 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=0, argc=-1072431104, argv=0x0, body=0xbffef1d0, nosuper=0) at eval.c:5603 #39 0x00202ca4 in rb_call (klass=689956, recv=0, mid=3221144352, argc=493476, argv=0x0, scope=2708280) at eval.c:5696 #40 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #41 0x001fc350 in rb_eval (self=3259744661, n=0x62edf0) at eval.c:2943 #42 0x002027fc in rb_call0 (klass=3259744661, recv=2273678227, id=3259744661, oid=3221156372, argc=1127219200, argv=0x80000000, body=0x4081c800, nosuper=0) at eval.c:5603 #43 0x00202ca4 in rb_call (klass=455416, recv=3221156372, mid=3221156336, argc=493516, argv=0x1, scope=0) at eval.c:5696 #44 0x001fd1d0 in rb_eval (self=454776, n=0x62edf0) at ruby.h:634 #45 0x002027fc in rb_call0 (klass=454616, recv=454776, id=13777, oid=484956, argc=0, argv=0x0, body=0x765bc, nosuper=0) at eval.c:5603 #46 0x00202ca4 in rb_call (klass=454616, recv=484956, mid=3221168400, argc=453876, argv=0x0, scope=0) at eval.c:5696 #47 0x001fd4f8 in rb_eval (self=454776, n=0x62edf0) at ruby.h:634 #48 0x002027fc in rb_call0 (klass=454616, recv=454776, id=5041, oid=487856, argc=0, argv=0x0, body=0x7714c, nosuper=0) at eval.c:5603 #49 0x00202ca4 in rb_call (klass=454616, recv=487856, mid=3221175008, argc=0, argv=0x0, scope=0) at eval.c:5696 #50 0x001fd1d0 in rb_eval (self=454616, n=0x62edf0) at ruby.h:634 #51 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=664116, argc=-1072431104, argv=0x0, body=0xbfff6eb0, nosuper=0) at eval.c:5603 #52 0x00202ca4 in rb_call (klass=662296, recv=664116, mid=3221181616, argc=454776, argv=0x0, scope=0) at eval.c:5696 #53 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #54 0x001fcfcc in rb_eval (self=519676, n=0x62edf0) at eval.c:3217 #55 0x002027fc in rb_call0 (klass=3222536192, recv=0, id=3221200240, oid=3221188344, argc=2108580, argv=0x87859393, body=0xc24bc195, nosuper=0) at eval.c:5603 #56 0x00202ca4 in rb_call (klass=522456, recv=3221188344, mid=3221188304, argc=454616, argv=0x2, scope=0) at eval.c:5696 #57 0x001fd1d0 in rb_eval (self=522456, n=0x62edf0) at ruby.h:634 #58 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=686876, argc=-1072431104, argv=0x0, body=0xbfffb770, nosuper=0) at eval.c:5603 #59 0x00202ca4 in rb_call (klass=522436, recv=686876, mid=3221200240, argc=519676, argv=0x0, scope=2708280) at eval.c:5696 #60 0x001fd1d0 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634 #61 0x001fd288 in rb_eval (self=3222536192, n=0x62edf0) at eval.c:3233 #62 0x00200724 in rb_yield_0 (val=520556, self=227808, klass=0, flags=-1073760368, avalue=2) at eval.c:4687 #63 0x00207bf4 in proc_invoke (proc=521396, args=520556, self=6, klass=3221206928) at ruby.h:634 #64 0x002061d4 in call_end_proc (data=522456) at eval.c:7363 #65 0x00206524 in rb_exec_end_proc () at eval.c:7444 #66 0x001f8a9c in ruby_finalize_0 () at eval.c:1390 #67 0x001f8b78 in ruby_cleanup (ex=0) at eval.c:1418 #68 0x001f8dc4 in ruby_stop (ex=970752) at eval.c:1465 #69 0x001f8e28 in ruby_run () at eval.c:1477 #70 0x00001d84 in main (argc=0, argv=0x0, envp=0x617a6572) at main.c:50 #71 0x00001a84 in _start (argc=3, argv=0xbffffd30, envp=0xbffffd40) at /SourceCache/Csu/Csu-46/crt.c:267 #72 0x000018f8 in start () Thanks, Mark