GC Bug? Ruby 1.8.4 core dumps on a very small extension

D

Danie Roux

------=_Part_5417_23979799.1140389244192
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi all,

Long (and tiring) story short:

I have an extension that is 40 lines* in total, the C code and Ruby
code that exercise it. It core dumps, while I repeatedly call a method
that just returns Qtrue.

All it really does is:

rb_iv_set(self, "@v", 100);

in initialize. If I change that 100 to 99, it doesn't core dump.
Change it back to 100, it core dumps within a few seconds.

Further, the while loop that executes it looks like this:

while true
print ''
b.buzz
end

If I take out the print statement, it keeps on running. Put back the
print statement, and it core dumps.

This is a self-compiled 1.8.4 on Ubuntu i386. A friend confirms that
the same thing happens to him on Gentoo with 1.8.4.

I am attaching the code, hopefully its going to come through.

* It was around 600, and use to core dump every 8 hours or so.
Snipping it down to these 40 lines was pure blind luck, and many 8
hour turnaround iterations.

--
Danie Roux *shuffle* Adore Unix http://blog.acolyte.co.za

------=_Part_5417_23979799.1140389244192
Content-Type: application/x-gzip; name=funny_fail.tar.gz
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ejvyb2w4
Content-Disposition: attachment; filename="funny_fail.tar.gz"

H4sIANvv+EMAA+2WXWvbMBSGfa1fIbxBHAiulfgD1nVsgxYKhbGL9db44xhrtZVNktMlpf99kkMS
t7TLLpKObee5cfTmHOk4J684VSfEMq0y3pw4xyIwJFFknyyJguFzg8OCWRKzOElY7ASMxWHs0Oho
FQ3olM4kpU7DK/hV3L7v/1KqXf+VlqCUL/NDn2EbHIfhs/1nYbLpfxjGRmeziDGHBocu5Cn+8/6/
fuN3QtW80vSCN+CXXIqsBS9NLy6vztN0TIiE7x2XQEd5t1qNCMnPPpoPvoBbQm5rk0S17IBQwzfJ
haajUb/IfZtAQJSE/OnXRJ5h4H/4oYu5qA5/Aezzf7Dz/zROZtb/8SxB/78EW3O3N201IoWETEPa
ZjdQGWd7rrWwO0b//qsM/G9b7RdHOGOf/+2wt5n/pklk/R+wKfr/JXjFRdF0JVBXdvnSr11CttJb
pUs+9+t3A6kT3KgPNbVUJ+s4Yn5MzQt6/eHqyzkt7Jxw+kjkgmueNXwF3lpQ0FRjctePDDJP+SJV
oD2rTqj7fuFOKAuCsdmmDwDdSdHnnJL7R1vbP/BwU3r3IOmzHVP6rMWcl/TSFJL2KTbQxvX10jNb
RWmuPwFp0WRKea7VTR1GLz7lX6HQ23K2kS3oel56/Ram7t1bmrzdYkKDvan5+rC8X/Xh93j9IgiC
IAiCIAiCIAiCIAiCIAiCIL/JT4oQxrQAKAAA
------=_Part_5417_23979799.1140389244192--
 
R

Ross Bamford

Hi all,

Long (and tiring) story short:

I have an extension that is 40 lines* in total, the C code and Ruby
code that exercise it. It core dumps, while I repeatedly call a method
that just returns Qtrue.

Please try making this change:

--- buzz-orig.c 2006-02-19 23:01:22.000000000 +0000
+++ buzz.c 2006-02-19 23:01:56.000000000 +0000
@@ -8,7 +8,7 @@

static VALUE initialize(VALUE self)
{
- rb_iv_set(self, "@v", 100);
+ rb_iv_set(self, "@v", INT2FIX(100));

return self;
}
 
D

Danie Roux

Please try making this change:
- rb_iv_set(self, "@v", 100);
+ rb_iv_set(self, "@v", INT2FIX(100));

Ross,

Thank you. Moral of the story: Explicitly cast any C value into a Ruby one.

It still strikes me odd that it would run a couple of hundred
iterations before breaking, though.
 
C

Charles Mills

Danie said:
Ross,

Thank you. Moral of the story: Explicitly cast any C value into a Ruby one.

It still strikes me odd that it would run a couple of hundred
iterations before breaking, though.

Assuming you're using a 32bit machine. 100 % 4 == 0, so Ruby thinks
100 is a pointer to a Ruby object. (Dereferencing 100 causes the core
dump.) 99 % 2 == 1, so 99 looks like a Fixnum to Ruby -- but not 99,
99>>1 I think.

It may take a couple hundred iterations before the GC runs.

-Charlie
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top