We still encountered a gc_sweep in our use of Ruby 1.8 on Linux (v8).

The stdout message is:

/usr/lib/ruby/1.8/net/protocol.rb:196: [BUG] obj_free() called for 
broken object ruby 1.8.0 (2003-08-08) [i686-linux]
./runs1123: line 6:  9928 Aborted                 (core dumped) ruby 
SAVE-P-PreStage7.rb

That part of protocol.rb is:

195    def rbuf_fill
196*     until IO.select([@socket], nil, nil, @read_timeout)
197       raise TimeoutError, "socket read timeout (#{@read_timeout} 
sec)"
198      end
199      @rbuf << @socket.sysread(1024)
200    end

That this is doing IO.select seems consistent with the fact that these 
gc_sweep issues which were happening all the time were reduced (and I 
thought eliminated) when we removed $stdout.sync=true which was in one 
of our libraries.  I appears to have something to do with select and gc 
operations.

Anyway...

Here is the gdb analysis of the core dump:

[asmt@sv022 scripts]$ gdb /usr/bin/ruby core.9928
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and 
you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for 
details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `ruby SAVE-P-PreStage7.rb'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/ruby/1.8/i686-linux/socket.so...done.
Loaded symbols for /usr/lib/ruby/1.8/i686-linux/socket.so
Reading symbols from 
/mnt/shared/socVA/csmart/assessment/lib/postgres.so...done.
Loaded symbols for /mnt/shared/socVA/csmart/assessment/lib/postgres.so
Reading symbols from /usr/lib/libpq.so.2...done.
Loaded symbols for /usr/lib/libpq.so.2
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libssl.so.2...done.
Loaded symbols for /lib/libssl.so.2
Reading symbols from /lib/libcrypto.so.2...done.
Loaded symbols for /lib/libcrypto.so.2
Reading symbols from /usr/kerberos/lib/libkrb5.so.3...done.
Loaded symbols for /usr/kerberos/lib/libkrb5.so.3
Reading symbols from /usr/kerberos/lib/libk5crypto.so.3...done.
Loaded symbols for /usr/kerberos/lib/libk5crypto.so.3
Reading symbols from /usr/kerberos/lib/libcom_err.so.3...done.
Loaded symbols for /usr/kerberos/lib/libcom_err.so.3
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/ruby/1.8/i686-linux/openssl.so...done.
Loaded symbols for /usr/lib/ruby/1.8/i686-linux/openssl.so
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_nisplus.so.2...done.
Loaded symbols for /lib/libnss_nisplus.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /usr/lib/ruby/1.8/i686-linux/digest/sha1.so...done.
Loaded symbols for /usr/lib/ruby/1.8/i686-linux/digest/sha1.so
Reading symbols from /usr/lib/ruby/1.8/i686-linux/digest.so...done.
Loaded symbols for /usr/lib/ruby/1.8/i686-linux/digest.so
#0  0x42028cc1 in kill () from /lib/i686/libc.so.6

Here is the current stack:

(gdb) where
#0  0x42028cc1 in kill () from /lib/i686/libc.so.6
#1  0x42028ac8 in raise () from /lib/i686/libc.so.6
#2  0x4202a019 in abort () from /lib/i686/libc.so.6
#3  0x080b9774 in rb_check_type (x=1108517584, t=6) at error.c:193
#4  0x0806a636 in obj_free (obj=1074200648) at gc.c:1150
#5  0x0806a38d in gc_sweep () at gc.c:939
#6  0x0806a84f in rb_gc () at gc.c:1299
#7  0x080692e1 in ruby_xmalloc (size=4) at gc.c:106
#8  0x080ae290 in ary_new (klass=1074370424, len=1) at array.c:118
#9  0x080ae2d0 in rb_ary_new2 (len=1) at array.c:128
#10 0x08057386 in rb_eval (self=1137407792, n=0x0) at eval.c:3330
#11 0x08056ed5 in rb_eval (self=1137407792, n=0x0) at ruby.h:631
#12 0x08055f4d in rb_eval (self=1137407792, n=0x0) at eval.c:2679
#13 0x0805b01a in rb_call0 (klass=1076504320, recv=1137407792, 
id=27697, oid=0, argc=0, argv=0x0, body=0x402a9a78, nosuper=0) at 
eval.c:5032
#14 0x0805b4d1 in rb_call (klass=1076504320, recv=1137407792, 
mid=27697, argc=0, argv=0x0, scope=2) at eval.c:5122
#15 0x08056e33 in rb_eval (self=1137407792, n=0x0) at eval.c:2994
#16 0x08055e40 in rb_eval (self=1137407792, n=0x0) at eval.c:2647
#17 0x08056661 in rb_eval (self=1137407792, n=0x0) at eval.c:2812
#18 0x0805b01a in rb_call0 (klass=1076504320, recv=1137407792, 
id=27449, oid=0, argc=0, argv=0xbfff0634, body=0x402ab378, nosuper=0) 
at eval.c:5032
#19 0x0805b4d1 in rb_call (klass=1076504320, recv=1137407792, 
mid=27449, argc=1, argv=0xbfff0630, scope=0) at eval.c:5122
#20 0x08056e33 in rb_eval (self=1137404572, n=0x0) at eval.c:2994
#21 0x0805b01a in rb_call0 (klass=1076495880, recv=1137404572, 
id=27425, oid=0, argc=0, argv=0xbfff0d44, body=0x402afa18, nosuper=0) 
at eval.c:5032
#22 0x0805b4d1 in rb_call (klass=1076495880, recv=1137404572, 
mid=27425, argc=1, argv=0xbfff0d40, scope=1) at eval.c:5122
#23 0x08056e33 in rb_eval (self=1137404572, n=0x0) at eval.c:2994
#24 0x080556a9 in rb_eval (self=1137404572, n=0x0) at eval.c:2462
#25 0x0805b01a in rb_call0 (klass=1076495880, recv=1137404572, 
id=26321, oid=0, argc=0, argv=0x0, body=0x402b08b4, nosuper=0) at 
eval.c:5032
#26 0x0805b4d1 in rb_call (klass=1076495880, recv=1137404572, 
mid=26321, argc=0, argv=0x0, scope=1) at eval.c:5122
#27 0x08056e33 in rb_eval (self=1137404572, n=0x0) at eval.c:2994
#28 0x0805b01a in rb_call0 (klass=1076495880, recv=1137404572, 
id=20097, oid=0, argc=0, argv=0x0, body=0x402b0058, nosuper=0) at 
eval.c:5032
#29 0x0805b4d1 in rb_call (klass=1076495880, recv=1137404572, 
mid=20097, argc=0, argv=0x0, scope=0) at eval.c:5122
#30 0x08056e33 in rb_eval (self=1137404572, n=0x0) at eval.c:2994
#31 0x0805675b in rb_eval (self=1137404572, n=0x0) at eval.c:2852
---Type <return> to continue, or q <return> to quit---
#32 0x0805b01a in rb_call0 (klass=1076495880, recv=1137404572, 
id=26465, oid=0, argc=0, argv=0xbfff2c78, body=0x402b0d50, nosuper=0) 
at eval.c:5032
#33 0x0805b4d1 in rb_call (klass=1076495880, recv=1137404572, 
mid=26465, argc=2, argv=0xbfff2c70, scope=0) at eval.c:5122
#34 0x08056e33 in rb_eval (self=1137410872, n=0x0) at eval.c:2994
#35 0x08056279 in rb_eval (self=1137410872, n=0x0) at eval.c:2717
#36 0x0805b01a in rb_call0 (klass=1076501720, recv=1137410872, 
id=20449, oid=0, argc=0, argv=0xbfff38c8, body=0x4014e9e0, nosuper=0) 
at eval.c:5032
#37 0x0805b4d1 in rb_call (klass=1076501720, recv=1137410872, 
mid=20449, argc=2, argv=0xbfff38c0, scope=1) at eval.c:5122
#38 0x08056e33 in rb_eval (self=1137410872, n=0x0) at eval.c:2994
#39 0x0805fb65 in block_pass (self=1137410872, node=0x4014e2c4) at 
eval.c:7206
#40 0x0805788f in rb_eval (self=1137410872, n=0x0) at eval.c:2703
#41 0x0805744f in rb_eval (self=1137410872, n=0x0) at eval.c:2940
#42 0x0805952e in rb_yield_0 (val=1137410872, self=1137410872, klass=0, 
flags=0, avalue=0) at eval.c:4153
#43 0x080574c3 in rb_eval (self=1137410872, n=0x0) at eval.c:2802
#44 0x0805744f in rb_eval (self=1137410872, n=0x0) at eval.c:2940
#45 0x0805675b in rb_eval (self=1137410872, n=0x0) at eval.c:2852
#46 0x0805b01a in rb_call0 (klass=1076501720, recv=1137410872, id=5969, 
oid=0, argc=0, argv=0x0, body=0x40190fe8, nosuper=0) at eval.c:5032
#47 0x0805b4d1 in rb_call (klass=1076501720, recv=1137410872, mid=5969, 
argc=0, argv=0x0, scope=1) at eval.c:5122
#48 0x08056e33 in rb_eval (self=1137410872, n=0x0) at eval.c:2994
#49 0x08056279 in rb_eval (self=1137410872, n=0x0) at eval.c:2717
#50 0x0805b01a in rb_call0 (klass=1076501720, recv=1137410872, 
id=20449, oid=0, argc=0, argv=0xbfff68a8, body=0x4014e9e0, nosuper=0) 
at eval.c:5032
#51 0x0805b4d1 in rb_call (klass=1076501720, recv=1137410872, 
mid=20449, argc=2, argv=0xbfff68a0, scope=0) at eval.c:5122
#52 0x08056e33 in rb_eval (self=1076465360, n=0x0) at eval.c:2994
#53 0x08056817 in rb_eval (self=1076465360, n=0x0) at eval.c:3161
#54 0x0805b01a in rb_call0 (klass=1076464600, recv=1076465360, 
id=20825, oid=0, argc=0, argv=0xbfff7508, body=0x40110e60, nosuper=0) 
at eval.c:5032
#55 0x0805b4d1 in rb_call (klass=1076464600, recv=1076465360, 
mid=20825, argc=2, argv=0xbfff7500, scope=0) at eval.c:5122
#56 0x08056e33 in rb_eval (self=1079633444, n=0x0) at eval.c:2994
#57 0x08056817 in rb_eval (self=1079633444, n=0x0) at eval.c:3161
#58 0x0805b01a in rb_call0 (klass=1075933420, recv=1079633444, 
id=36345, oid=0, argc=0, argv=0xbfff814c, body=0x4021aa08, nosuper=0) 
at eval.c:5032
#59 0x0805b4d1 in rb_call (klass=1075933420, recv=1079633444, 
mid=36345, argc=3, argv=0xbfff8140, scope=1) at eval.c:5122
#60 0x08056e33 in rb_eval (self=1079633444, n=0x0) at eval.c:2994
#61 0x0805b01a in rb_call0 (klass=1075933420, recv=1079633444, 
id=13825, oid=0, argc=0, argv=0x0, body=0x40240474, nosuper=0) at 
eval.c:5032
#62 0x0805b4d1 in rb_call (klass=1075933420, recv=1079633444, 
mid=13825, argc=0, argv=0x0, scope=0) at eval.c:5122
#63 0x08056e33 in rb_eval (self=1079375404, n=0x0) at eval.c:2994
---Type <return> to continue, or q <return> to quit---
#64 0x08056661 in rb_eval (self=1079375404, n=0x0) at eval.c:2812
#65 0x0805675b in rb_eval (self=1079375404, n=0x0) at eval.c:2852
#66 0x080556a9 in rb_eval (self=1079375404, n=0x0) at eval.c:2462
#67 0x08055e40 in rb_eval (self=1079375404, n=0x0) at eval.c:2647
#68 0x0805b01a in rb_call0 (klass=1074689028, recv=1079375404, id=5969, 
oid=0, argc=0, argv=0x0, body=0x4007d9b0, nosuper=0) at eval.c:5032
#69 0x0805b4d1 in rb_call (klass=1074689028, recv=1079375404, mid=5969, 
argc=0, argv=0x0, scope=0) at eval.c:5122
#70 0x08056e33 in rb_eval (self=1079375444, n=0x0) at eval.c:2994
#71 0x080556a9 in rb_eval (self=1079375444, n=0x0) at eval.c:2462
#72 0x0805b01a in rb_call0 (klass=1074689328, recv=1079375444, id=5969, 
oid=0, argc=0, argv=0x0, body=0x400a17ec, nosuper=0) at eval.c:5032
#73 0x0805b4d1 in rb_call (klass=1074689328, recv=1079375444, mid=5969, 
argc=0, argv=0x0, scope=0) at eval.c:5122
#74 0x08056e33 in rb_eval (self=1079375624, n=0x0) at eval.c:2994
#75 0x0805952e in rb_yield_0 (val=1, self=1079375624, klass=0, flags=0, 
avalue=0) at eval.c:4153
#76 0x08059966 in rb_yield (val=1) at eval.c:4222
#77 0x0807a994 in int_dotimes (num=3) at numeric.c:1775
#78 0x0806525f in call_cfunc (func=0x807a95c <int_dotimes>, recv=3, 
len=1108517584, argc=0, argv=0x6) at eval.c:4767
#79 0x0805ad31 in rb_call0 (klass=1074375004, recv=3, id=6361, oid=0, 
argc=0, argv=0x0, body=0x4009a894, nosuper=0) at eval.c:4904
#80 0x0805b4d1 in rb_call (klass=1074375004, recv=3, mid=6361, argc=0, 
argv=0x0, scope=0) at eval.c:5122
#81 0x08056e33 in rb_eval (self=1079375624, n=0x0) at eval.c:2994
#82 0x08056279 in rb_eval (self=1079375624, n=0x0) at eval.c:2717
#83 0x0805b01a in rb_call0 (klass=1074691168, recv=1079375624, id=2953, 
oid=0, argc=0, argv=0xbfffc828, body=0x4025e208, nosuper=0) at 
eval.c:5032
#84 0x0805b4d1 in rb_call (klass=1074691168, recv=1079375624, mid=2953, 
argc=2, argv=0xbfffc820, scope=1) at eval.c:5122
#85 0x0805b7a3 in rb_funcall2 (recv=1108517584, mid=2953, argc=2, 
argv=0xbfffc820) at ruby.h:626
#86 0x0805d94e in rb_obj_call_init (obj=1079375624, argc=2, 
argv=0xbfffc820) at eval.c:6258
#87 0x0807c890 in rb_class_new_instance (argc=2, argv=0xbfffc820, 
klass=1074691168) at object.c:767
#88 0x0806525f in call_cfunc (func=0x807c870 <rb_class_new_instance>, 
recv=1074691168, len=1108517584, argc=2, argv=0x6) at eval.c:4767
#89 0x0805ad31 in rb_call0 (klass=1074400504, recv=1074691168, id=3353, 
oid=0, argc=2, argv=0xbfffc820, body=0x4009fb64, nosuper=0) at 
eval.c:4904
#90 0x0805b4d1 in rb_call (klass=1074400504, recv=1074691168, mid=3353, 
argc=2, argv=0xbfffc820, scope=0) at eval.c:5122
#91 0x08056e33 in rb_eval (self=1074691168, n=0x0) at eval.c:2994
#92 0x0805faa7 in block_pass (self=1074691168, node=0x400a7264) at 
eval.c:7243
#93 0x0805788f in rb_eval (self=1074691168, n=0x0) at eval.c:2703
#94 0x0805744f in rb_eval (self=1074691168, n=0x0) at eval.c:2940
#95 0x0805b01a in rb_call0 (klass=1074690388, recv=1074691168, id=5969, 
oid=0, argc=0, argv=0xbfffdb18, body=0x400a7304, nosuper=0) at 
eval.c:5032
---Type <return> to continue, or q <return> to quit---
#96 0x0805b4d1 in rb_call (klass=1074690388, recv=1074691168, mid=5969, 
argc=2, argv=0xbfffdb10, scope=0) at eval.c:5122
#97 0x08056e33 in rb_eval (self=1079375784, n=0x0) at eval.c:2994
#98 0x0805faa7 in block_pass (self=1079375784, node=0x400a7728) at 
eval.c:7243
#99 0x0805788f in rb_eval (self=1079375784, n=0x0) at eval.c:2703
#100 0x0805b01a in rb_call0 (klass=1074693268, recv=1079375784, 
id=6049, oid=0, argc=0, argv=0xbfffe8f4, body=0x400a79bc, nosuper=0) at 
eval.c:5032
#101 0x0805b4d1 in rb_call (klass=1074693268, recv=1079375784, 
mid=6049, argc=1, argv=0xbfffe8f0, scope=0) at eval.c:5122
#102 0x08056e33 in rb_eval (self=1074395744, n=0x0) at eval.c:2994
#103 0x08056279 in rb_eval (self=1074395744, n=0x0) at eval.c:2717
#104 0x08053634 in ruby_exec () at eval.c:1386
#105 0x08053668 in ruby_run () at eval.c:1407
#106 0x08051ae5 in main (argc=2, argv=0xbffff564, envp=0xbffff570) at 
main.c:50
#107 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6

Any analysis help would be great.

-rich