Segfault with map operation on 1.8p5

D

Daniel Berger

Hi all,

The following snippet is a silly thing to do, but I
thought it might be worth mentioning. It segfaults on
1.8p5, but not 1.6.x:

a = [1,2,3,4]
h = {}
a.map{ |e| h[e] = a.shift }

Suse Linux 8.0, btw.

Regards,

Dan

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
 
K

K.Sasada

[ Segfault with map operation on 1.8p5 ]
Thu, 31 Jul 2003 11:41:33 +0900
The following snippet is a silly thing to do, but I
thought it might be worth mentioning. It segfaults on
1.8p5, but not 1.6.x:

a = [1,2,3,4]
h = {}
a.map{ |e| h[e] = a.shift }


This problem is solved by following patch for ruby 1.8.0 p5.


regards,
--
// SASADA Koichi @ namikilab.tuat.ac.jp
//
// Thanks to unak :)


--- array.c.org Thu Jul 31 03:20:06 2003
+++ array.c Thu Jul 31 03:29:54 2003
@@ -1197,9 +1197,8 @@ rb_ary_collect(ary)
return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
}

- len = RARRAY(ary)->len;
collect = rb_ary_new2(len);
- for (i=0; i<len; i++) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr));
}
return collect;
 
U

U.Nakamura

Hello,

In message "Re: Segfault with map operation on 1.8p5"
| This problem is solved by following patch for ruby 1.8.0 p5.

Hmmm, this?

--- array.c 25 Jul 2003 05:36:46 -0000 1.128
+++ array.c 31 Jul 2003 04:03:48 -0000
@@ -1192,3 +1192,3 @@ rb_ary_collect(ary)
{
- long len, i;
+ long i;
VALUE collect;
@@ -1199,5 +1199,4 @@ rb_ary_collect(ary)

- len = RARRAY(ary)->len;
- collect = rb_ary_new2(len);
- for (i=0; i<len; i++) {
+ collect = rb_ary_new();
+ for (i = 0; i < RARRAY(ary)->len; i++) {
rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr));

Regards,
 
Y

Yukihiro Matsumoto

Hello,

In message "Re: Segfault with map operation on 1.8p5"

|In message "Re: Segfault with map operation on 1.8p5"
|| This problem is solved by following patch for ruby 1.8.0 p5.
|
|Hmmm, this?

Thank you guys for finding and fixing a bug.
Usa, could you commit this fix to the CVS?

matz.
 

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
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top