From: Masahiro TANAKA Date: 2002-01-25T11:04:25+09:00 Subject: Re: Modifying NArray's NVector dumps core? >From: Bil Kleb > Under certain conditions when we run our numerical simulation code it > dumps core as follows: > > $ ./Advect.rb -s1 > ./Vector.rb:13: [BUG] rb_gc_mark(): unknown data type 0x28(0x401ad4b0) non object > ruby 1.6.6 (2001-12-26) [i686-linux] > Aborted (core dumped) It's a bug in NArray. Thank you! Masa Tanaka --- na_array.c 2001/07/01 22:21:36 +++ na_array.c 2002/01/25 01:57:52 @@ -384,27 +384,29 @@ static VALUE na_to_array0(struct NARRAY* na, int *idx, int thisrank, void (*func)()) { - int i, pos; - struct RArray *ary; + int i, elmsz; + char *pos; + VALUE ary, val; /* Create New Array */ - ary = (struct RArray*)rb_ary_new2(na->shape[thisrank]); - ary->len = na->shape[thisrank]; + ary = rb_ary_new2(na->shape[thisrank]); if (thisrank == 0) { - for (i = 0; i < na->shape[thisrank]; i++) { - idx[thisrank] = i; - pos = na_index_pos(na,idx); - (*func)( 1, ary->ptr+i, 0, NA_PTR(na,pos), 0 ); + pos = NA_PTR( na, na_index_pos(na,idx) ); + elmsz = na_sizeof[na->type]; + for (i = na->shape[0]; i; i--) { + (*func)( 1, &val, 0, pos, 0 ); + pos += elmsz; + rb_ary_push( ary, val ); } } else { for (i = 0; i < na->shape[thisrank]; i++) { idx[thisrank] = i; - ary->ptr[i] = na_to_array0(na,idx,thisrank-1,func); + rb_ary_push( ary, na_to_array0(na,idx,thisrank-1,func) ); } } - return (VALUE)ary; + return ary; }