compiling mmap?

M

Mark Hubbart

Hi,
I'm having some trouble getting Guy's mmap to compile on my box. I was
certain that I had compiled it once before; but now I can't get it to
work. This is on MacOSX 10.3.3 (powerpc-darwin7.0). The initial failure
was that MCL_CURRENT and MLC_FUTURE are not defined:

mark@imac% make
gcc -fno-common -g -O2 -fno-common -pipe -fno-common
-DHAVE_RB_STR_LSTRIP -DHAVE_RB_STR_MATCH -DHAVE_RB_STR_INSERT
-DHAVE_RB_STR_CASECMP -I. -I/usr/local/lib/ruby/1.9/powerpc-darwin
-I/usr/local/lib/ruby/1.9/powerpc-darwin -I. -c mmap.c
mmap.c:1:2: invalid preprocessing directive #def
mmap.c: In function `Init_mmap':
mmap.c:1726: error: `MCL_CURRENT' undeclared (first use in this
function)
mmap.c:1726: error: (Each undeclared identifier is reported only once
mmap.c:1726: error: for each function it appears in.)
mmap.c:1727: error: `MCL_FUTURE' undeclared (first use in this function)
make: *** [mmap.o] Error 1

It appeared that they were supposed to be defined in 'mman.h', so I
looked in there:
---

#ifdef _P1003_1B_VISIBLE
/*
* Process memory locking
*/
#define MCL_CURRENT 0x0001 /* Lock only current memory */
#define MCL_FUTURE 0x0002 /* Lock all future memory as well */

#endif /* _P1003_1B_VISIBLE */

---
...and a quick search suggests that _P1003_1B_VISIBLE is undefined.

#defining _P1003_1B_VISIBLE at the top of mmap.c allows it to compile,
but running 'make test' generates a bus error on the 13th test.

Any help would be greatly appreciated.

thanks,
--Mark
 
T

ts

M> #defining _P1003_1B_VISIBLE at the top of mmap.c allows it to compile,
M> but running 'make test' generates a bus error on the 13th test.

it's best to do

svg% diff -u mmap.c~ mmap.c
--- mmap.c~ 2004-03-06 18:30:46.000000000 +0100
+++ mmap.c 2004-05-24 11:20:04.000000000 +0200
@@ -1722,9 +1722,10 @@
#ifdef MAP_NOSYNC
rb_define_const(mm_cMap, "MAP_NOSYNC", INT2FIX(MAP_NOSYNC));
#endif
+#ifdef MCL_CURRENT
rb_define_const(mm_cMap, "MCL_CURRENT", INT2FIX(MCL_CURRENT));
rb_define_const(mm_cMap, "MCL_FUTURE", INT2FIX(MCL_FUTURE));
-
+#endif
rb_include_module(mm_cMap, rb_mComparable);
rb_include_module(mm_cMap, rb_mEnumerable);

svg%

M> Any help would be greatly appreciated.

can you run it with gdb and give me a backtrace ?


Guy Decoux
 
M

Mark Hubbart

--Apple-Mail-7--269038399
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed


M> #defining _P1003_1B_VISIBLE at the top of mmap.c allows it to
compile,
M> but running 'make test' generates a bus error on the 13th test.

it's best to do

svg% diff -u mmap.c~ mmap.c
--- mmap.c~ 2004-03-06 18:30:46.000000000 +0100
+++ mmap.c 2004-05-24 11:20:04.000000000 +0200
@@ -1722,9 +1722,10 @@
#ifdef MAP_NOSYNC
rb_define_const(mm_cMap, "MAP_NOSYNC", INT2FIX(MAP_NOSYNC));
#endif
+#ifdef MCL_CURRENT
rb_define_const(mm_cMap, "MCL_CURRENT", INT2FIX(MCL_CURRENT));
rb_define_const(mm_cMap, "MCL_FUTURE", INT2FIX(MCL_FUTURE));
-
+#endif
rb_include_module(mm_cMap, rb_mComparable);
rb_include_module(mm_cMap, rb_mEnumerable);

svg%

I tried this, and while it still crashes on the tests, it makes it
plenty stable for me to play with it. thanks much :)
M> Any help would be greatly appreciated.

can you run it with gdb and give me a backtrace ?

I attached it at the end of the message. I hope I did it right :)
Guy Decoux


--Apple-Mail-7--269038399
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-mac-type=54455854;
x-unix-mode=0644;
x-mac-creator=48647261;
name="bt"
Content-Disposition: attachment;
filename=bt

(gdb) run -d mmapt.rb
Starting program: /usr/local/bin/ruby -d mmapt.rb
mmapt.rb:2: warning: `*' interpreted as argument prefix
Reading symbols for shared libraries . done
Loaded suite 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=1787828, ptr=0x62edf0 "azertyuiopqsdfghjklm", len=20) at mmap.c:1103
#2 0x0004dcd0 in mm_append (str1=1787828, str2=1788668) at mmap.c:1115
#3 0x0004dd24 in mm_concat (str1=950272, str2=6483440) at mmap.c:1130
#4 0x00202370 in rb_call0 (klass=105528, recv=1787828, id=334, oid=334, argc=1, argv=0xbffda490, body=0x190a8, nosuper=0) at eval.c:5479
#5 0x00202ca4 in rb_call (klass=105528, 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=520736, recv=3221070996, mid=3221070960, argc=1787828, argv=0x1, scope=0) at eval.c:5696
#10 0x00202ed0 in rb_f_send (argc=0, argv=0xbffdd9b4, recv=490416) at ruby.h:634
#11 0x00202370 in rb_call0 (klass=232608, recv=490416, id=3905, oid=490416, argc=1, argv=0xbffdd9b0, body=0x36d60, nosuper=0) at eval.c:5479
#12 0x00202ca4 in rb_call (klass=232608, recv=490416, mid=3221084596, argc=491896, argv=0x2a2dc8, scope=520736) at eval.c:5696
#13 0x001fd434 in rb_eval (self=3222536192, n=0x62edf0) at ruby.h:634
#14 0x001fc850 in rb_eval (self=490416, n=0x62edf0) at eval.c:3054
#15 0x001fc99c in rb_eval (self=490416, 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=688856, 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=491636, node=0xa9430) at eval.c:8357
#20 0x001fc194 in rb_eval (self=491636, n=0x62edf0) at eval.c:2929
#21 0x00200724 in rb_yield_0 (val=490416, self=491636, 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=490996, 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=491636, n=0x62edf0) at ruby.h:634
#26 0x001fc350 in rb_eval (self=491636, 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=690036, recv=0, mid=3221117104, argc=490996, 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=493596, node=0xa9430) at eval.c:8357
#31 0x001fc194 in rb_eval (self=493596, n=0x62edf0) at eval.c:2929
#32 0x00200724 in rb_yield_0 (val=491636, self=493596, 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=493556, 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=493596, n=0x62edf0) at ruby.h:634
#37 0x001fc350 in rb_eval (self=493596, 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=690036, recv=0, mid=3221144352, argc=493556, 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=455496, recv=3221156372, mid=3221156336, argc=493596, argv=0x1, scope=0) at eval.c:5696
#44 0x001fd1d0 in rb_eval (self=454856, n=0x62edf0) at ruby.h:634
#45 0x002027fc in rb_call0 (klass=454696, recv=454856, id=13777, oid=485036, argc=0, argv=0x0, body=0x7660c, nosuper=0) at eval.c:5603
#46 0x00202ca4 in rb_call (klass=454696, recv=485036, mid=3221168400, argc=453956, argv=0x0, scope=0) at eval.c:5696
#47 0x001fd4f8 in rb_eval (self=454856, n=0x62edf0) at ruby.h:634
#48 0x002027fc in rb_call0 (klass=454696, recv=454856, id=5041, oid=487936, argc=0, argv=0x0, body=0x7719c, nosuper=0) at eval.c:5603
#49 0x00202ca4 in rb_call (klass=454696, recv=487936, mid=3221175008, argc=0, argv=0x0, scope=0) at eval.c:5696
#50 0x001fd1d0 in rb_eval (self=454696, n=0x62edf0) at ruby.h:634
#51 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=664196, argc=-1072431104, argv=0x0, body=0xbfff6eb0, nosuper=0) at eval.c:5603
#52 0x00202ca4 in rb_call (klass=662376, recv=664196, mid=3221181616, argc=454856, 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=519756, 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=522536, recv=3221188344, mid=3221188304, argc=454696, argv=0x2, scope=0) at eval.c:5696
#57 0x001fd1d0 in rb_eval (self=522536, n=0x62edf0) at ruby.h:634
#58 0x002027fc in rb_call0 (klass=1127219200, recv=2147483648, id=1082247168, oid=686956, argc=-1072431104, argv=0x0, body=0xbfffb770, nosuper=0) at eval.c:5603
#59 0x00202ca4 in rb_call (klass=522516, recv=686956, mid=3221200240, argc=519756, 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=520636, self=227808, klass=0, flags=-1073760368, avalue=2) at eval.c:4687
#63 0x00207bf4 in proc_invoke (proc=521476, args=520636, self=6, klass=3221206928) at ruby.h:634
#64 0x002061d4 in call_end_proc (data=522536) 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=950272) 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=0xbffffd2c, envp=0xbffffd3c) at /SourceCache/Csu/Csu-46/crt.c:267
#72 0x000018f8 in start ()

--Apple-Mail-7--269038399
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed



--Apple-Mail-7--269038399--
 
T

ts

M> Program received signal EXC_BAD_ACCESS, Could not access memory.

Can you try to change in tests/mmapt.rb at the line 302 "w" with "rw"

298 def test_13_div
299 string = "azertyuiopqsdfghjklm"
300 assert_kind_of(Mmap, m0 = Mmap.new("tmp/aa", "a"), "new a")
301 File.open("tmp/bb", "w") {|f| f.puts "aaa" }
302 assert_kind_of(Mmap, m1 = Mmap.new("tmp/bb", "w"), "new a")

assert_kind_of(Mmap, m1 = Mmap.new("tmp/bb", "rw"), "new a")


Guy Decoux
 
M

Mark Hubbart

M> Program received signal EXC_BAD_ACCESS, Could not access memory.

Can you try to change in tests/mmapt.rb at the line 302 "w" with "rw"

tests finish now, no bus error...

Loaded suite mmapt
Started
.............FF
Finished in 5.995658 seconds.

1) Failure:
test_13_div(TestMmap) [mmapt.rb:304]:
empty.
<true> expected but was
<false>.

2) Failure:
test_14_other(TestMmap) [mmapt.rb:332]:
content.
<"azertyuiopqsdfghjklm"> expected but was
<"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0
00\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0
00\000\000\000\000">.

15 tests, 3061 assertions, 2 failures, 0 errors

---

I snipped out most of the null characters in the second failure...
there were actually 4096 of them.

Thanks,
Mark
 
T

ts

M> test_13_div(TestMmap) [mmapt.rb:304]:
M> empty.
M> <true> expected but was
M> <false>.

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")

Now, why it need PROT_READ ???



Guy Decoux
 
M

Mark Hubbart

M> test_13_div(TestMmap) [mmapt.rb:304]:
M> empty.
M> <true> expected but was
M> <false>.

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
 
T

ts

M> Program received signal EXC_BAD_ACCESS, Could not access memory.

can you run this, to see which test fail

svg% cat b.rb
#!/usr/bin/ruby
require 'mmap'
m0 = Mmap.new("/tmp/aa", "a")
m0 << "abcdef"
puts m0
File.open("/tmp/bb", "w") {|f| f.puts "aaa" }
m1 = Mmap.new("/tmp/bb", "w")
m1 << "abcdef"
puts m1
svg%

svg% b.rb
#<Mmap:0x40098b5c>
#<Mmap:0x40098a94>
svg%


Guy Decoux
 
M

Mark Hubbart

#!/usr/bin/ruby
require 'mmap'
m0 = Mmap.new("/tmp/aa", "a")
m0 << "abcdef"
puts m0
File.open("/tmp/bb", "w") {|f| f.puts "aaa" }
m1 = Mmap.new("/tmp/bb", "w")
m1 << "abcdef"
puts m1

mark@imac% pbpaste | ruby
#<Mmap:0x27270>
-:8: [BUG] Bus Error
ruby 1.9.0 (2004-04-11) [powerpc-darwin]

zsh: done pbpaste |
zsh: abort ruby



it looks like the second test...

thanks,
Mark
 
B

Brian Feldman

#!/usr/bin/ruby
require 'mmap'
m0 = Mmap.new("/tmp/aa", "a")
m0 << "abcdef"
puts m0
File.open("/tmp/bb", "w") {|f| f.puts "aaa" }
m1 = Mmap.new("/tmp/bb", "w")
m1 << "abcdef"
puts m1

mark@imac% pbpaste | ruby
#<Mmap:0x27270>
-:8: [BUG] Bus Error
ruby 1.9.0 (2004-04-11) [powerpc-darwin]

zsh: done pbpaste |
zsh: abort ruby



it looks like the second test...

Looks like Darwin does not automatically translate PROT_WRITE into
PROT_READ | PROT_WRITE. The concept of write-only memory regions in
userland programs is pretty strange... disassemble the instruction
currently executing and it's probably a RMW instruction. Allowing
the user to specify PROT_WRITE alone probably shouldn't happen in
Ruby.
 
T

ts

B> Looks like Darwin does not automatically translate PROT_WRITE into
B> PROT_READ | PROT_WRITE. The concept of write-only memory regions in
B> userland programs is pretty strange... disassemble the instruction
B> currently executing and it's probably a RMW instruction. Allowing
B> the user to specify PROT_WRITE alone probably shouldn't happen in
B> Ruby.

Well, not really the patch that have given in [ruby-talk:101215] was
precisely to have PROT_READ | PROT_WRITE in this case.

Actually I don't see the difference between the 2 test, except that the
second add the flag O_TRUNC when the file is opened.


Guy Decoux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top