Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Charlie Savage
RE: segmentation fault [ reply ]  
2009-03-06 05:52
Stephen,

Fix is now released as part of 0.9.9. Let me know how it works for you.

Charlie

By: Stephen Sykes
RE: segmentation fault [ reply ]  
2009-03-01 13:36
Thanks Charlie!
- Stephen

By: Charlie Savage
RE: segmentation fault [ reply ]  
2009-02-28 23:50
Hi Stephen,

Nice catch. Fix is now in trunk (and also for xml/html parser contexts).

By: Stephen Sykes
RE: segmentation fault [ reply ]  
2009-02-19 16:11
Hmm, actually it didn't go away, it just occurred at a different time.

The issue is that if you call XML::Reader.io(io) libxml-ruby does not keep a reference to the io object around. If that io object goes out of scope in your own code then it will be GC'd and a segfault will result next time you use the reader.

This could be fixed in ruby_xml_reader.c by putting the io object in an instance variable of the reader that is returned?

-Stephen

By: Stephen Sykes
RE: segmentation fault [ reply ]  
2009-02-18 16:25
Hi, sorry for the noise, I think the ruby I was using was causing it. A fresh copy of ruby with standard options, and the problem has gone away.

By: Stephen Sykes
RE: segmentation fault [ reply ]  
2009-02-18 15:27
And here is the gdb backtrace output with more information, you can see the line numbers from libxml_ruby now:

#0 st_lookup (table=0x0, key=7657, value=0x7fffb6ee5700) at st.c:250
#1 0x0000000000411405 in search_method (klass=46912574519880, id=7657, origin=0x7fffb6ee5738) at eval.c:497
#2 0x0000000000411477 in rb_get_method_body (klassp=0x7fffb6ee5780, idp=0x7fffb6ee5788, noexp=0x7fffb6ee5794) at eval.c:518
#3 0x0000000000418985 in rb_call (klass=46912574519880, recv=46912574519920, mid=7657, argc=1, argv=0x7fffb6ee57e0,
scope=1, self=6) at eval.c:6270
#4 0x0000000000418f68 in vafuncall (recv=46912574519920, mid=7657, n=7172480, ar=<value optimized out>) at eval.c:6372
#5 0x00000000004191f3 in rb_funcall (recv=0, mid=7657, n=-1225894144) at eval.c:6389
#6 0x00002aaab0e9e7cf in rxml_read_callback (context=0x0, buffer=0x305bee0 "", len=<value optimized out>)
at ruby_xml_io.c:15
#7 0x0000003e1e659e50 in xmlParserInputBufferGrow () from /usr/lib64/libxml2.so.2
#8 0x0000003e1e6d89a5 in localtime () from /usr/lib64/libxml2.so.2
#9 0x0000003e1e6d96d3 in xmlTextReaderRead () from /usr/lib64/libxml2.so.2
#10 0x00002aaab0e9da71 in rxml_reader_read (self=<value optimized out>) at ruby_xml_reader.c:404
#11 0x0000000000417cba in rb_call0 (klass=46912576137680, recv=46912574519680, id=7657, oid=7657, argc=0, argv=0x0,
body=0x2aaaaf6f9f80, flags=<value optimized out>) at eval.c:6048
#12 0x00000000004189c8 in rb_call (klass=46912576137680, recv=46912574519680, mid=7657, argc=0, argv=0x0, scope=0,
self=46912574519480) at eval.c:6295
#13 0x000000000042371b in eval_call (self=46912574519480, node=0x2aaaaf717d00) at eval.c:3368
#14 0x0000000000417340 in rb_eval (self=46912574519480, node=0x2aaaaf717d50) at eval.c:4085
#15 0x0000000000416b6e in rb_eval (self=46912574519480, node=0x2aaaaf717b20) at eval.c:3843
#16 0x0000000000418510 in rb_call0 (klass=46912575125440, recv=46912574519480, id=119321, oid=<value optimized out>, argc=0,
argv=0x0, body=0x2aaaaf717b20, flags=<value optimized out>) at eval.c:6199
#17 0x00000000004189c8 in rb_call (klass=46912575125440, recv=46912574519480, mid=119321, argc=0, argv=0x0, scope=2,
self=46912574519480) at eval.c:6295
#18 0x00000000004175cc in rb_eval (self=46912574519480, node=0x2aaaaf718ed0) at eval.c:4044
#19 0x0000000000416b6e in rb_eval (self=46912574519480, node=0x2aaaaf718700) at eval.c:3843
#20 0x00000000004247dc in eval_while (self=46912574519480, node=0x2aaaaf718688) at eval.c:3101
#21 0x0000000000416b6e in rb_eval (self=46912574519480, node=0x2aaaaf718610) at eval.c:3843
#22 0x0000000000418510 in rb_call0 (klass=46912575125440, recv=46912574519480, id=119233, oid=<value optimized out>, argc=0,
argv=0x7fffb6ee6518, body=0x2aaaaf718638, flags=<value optimized out>) at eval.c:6199
#23 0x00000000004189c8 in rb_call (klass=46912575125440, recv=46912574519480, mid=119233, argc=1, argv=0x7fffb6ee6510,
scope=0, self=46912575039760) at eval.c:6295
#24 0x000000000042371b in eval_call (self=46912575039760, node=0x2aaaaf71f078) at eval.c:3368
#25 0x0000000000416edf in rb_eval (self=46912575039760, node=0x2aaaaf71f050) at eval.c:3955
#26 0x00000000004172ff in rb_eval (self=46912575039760, node=0x2aaaaf71f190) at eval.c:4079
#27 0x0000000000416b6e in rb_eval (self=46912575039760, node=0x2aaaaf71e718) at eval.c:3843
#28 0x0000000000423fd2 in eval_rescue (self=46912575039760, node=0x2aaaaf71e268) at eval.c:3225
#29 0x0000000000417602 in rb_eval (self=46912575039760, node=0x2aaaaf71e268) at eval.c:3976
#30 0x0000000000416035 in rb_yield_0 (val=6, self=46912575039760, klass=0, flags=<value optimized out>, avalue=0)
at eval.c:5218
#31 0x000000000041d49c in loop_i () at eval.c:5353

By: Stephen Sykes
segmentation fault [ reply ]  
2009-02-18 11:56
Hi, I'm getting a seg fault with ruby 1.8.7, on x86_64-linux.

I ran under gdb to get you some information about it, see below.

I have tried to extract a test case from my code, but without success yet. When the segfault happens is probably affected by how many objects there are, and when GC has run. The segfault does not occur when GC is disabled.

Here is gdb output:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912496215408 (LWP 24251)]
st_lookup (table=0x0, key=7657, value=0x7fffdfd54590) at st.c:250
250 hash_val = do_hash(key, table);
(gdb) bt
#0 st_lookup (table=0x0, key=7657, value=0x7fffdfd54590) at st.c:250
#1 0x0000000000411405 in search_method (klass=46912574519960, id=7657, origin=0x7fffdfd545c8) at eval.c:497
#2 0x0000000000411477 in rb_get_method_body (klassp=0x7fffdfd54610, idp=0x7fffdfd54618, noexp=0x7fffdfd54624) at eval.c:518
#3 0x0000000000418985 in rb_call (klass=46912574519960, recv=46912574520000, mid=7657, argc=1, argv=0x7fffdfd54670,
scope=1, self=6) at eval.c:6270
#4 0x0000000000418f68 in vafuncall (recv=46912574520000, mid=7657, n=7173728, ar=<value optimized out>) at eval.c:6372
#5 0x00000000004191f3 in rb_funcall (recv=0, mid=7657, n=-539671152) at eval.c:6389
#6 0x00002aaab0e9eabf in rxml_read_callback () from /usr/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.8/lib/libxml_ruby.so
#7 0x0000003e1e659e50 in xmlParserInputBufferGrow () from /usr/lib64/libxml2.so.2
#8 0x0000003e1e6d89a5 in localtime () from /usr/lib64/libxml2.so.2
#9 0x0000003e1e6d96d3 in xmlTextReaderRead () from /usr/lib64/libxml2.so.2
#10 0x00002aaab0e9df17 in rxml_reader_read () from /usr/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.8/lib/libxml_ruby.so
#11 0x0000000000417cba in rb_call0 (klass=46912576137760, recv=46912574519760, id=7657, oid=7657, argc=0, argv=0x0,
body=0x2aaaaf6f9fd0, flags=<value optimized out>) at eval.c:6048
#12 0x00000000004189c8 in rb_call (klass=46912576137760, recv=46912574519760, mid=7657, argc=0, argv=0x0, scope=0,
self=46912574519560) at eval.c:6295
#13 0x000000000042371b in eval_call (self=46912574519560, node=0x2aaaaf717d00) at eval.c:3368
#14 0x0000000000417340 in rb_eval (self=46912574519560, node=0x2aaaaf717d50) at eval.c:4085
#15 0x0000000000416b6e in rb_eval (self=46912574519560, node=0x2aaaaf717b20) at eval.c:3843
#16 0x0000000000418510 in rb_call0 (klass=46912575125520, recv=46912574519560, id=119321, oid=<value optimized out>, argc=0,
argv=0x0, body=0x2aaaaf717b20, flags=<value optimized out>) at eval.c:6199
#17 0x00000000004189c8 in rb_call (klass=46912575125520, recv=46912574519560, mid=119321, argc=0, argv=0x0, scope=2,
self=46912574519560) at eval.c:6295
#18 0x00000000004175cc in rb_eval (self=46912574519560, node=0x2aaaaf718ed0) at eval.c:4044
#19 0x0000000000416b6e in rb_eval (self=46912574519560, node=0x2aaaaf718700) at eval.c:3843
#20 0x00000000004247dc in eval_while (self=46912574519560, node=0x2aaaaf718688) at eval.c:3101
#21 0x0000000000416b6e in rb_eval (self=46912574519560, node=0x2aaaaf718610) at eval.c:3843
#22 0x0000000000418510 in rb_call0 (klass=46912575125520, recv=46912574519560, id=119233, oid=<value optimized out>, argc=0,
argv=0x7fffdfd553a8, body=0x2aaaaf718638, flags=<value optimized out>) at eval.c:6199
#23 0x00000000004189c8 in rb_call (klass=46912575125520, recv=46912574519560, mid=119233, argc=1, argv=0x7fffdfd553a0,
scope=0, self=46912575039840) at eval.c:6295
#24 0x000000000042371b in eval_call (self=46912575039840, node=0x2aaaaf71f078) at eval.c:3368
#25 0x0000000000416edf in rb_eval (self=46912575039840, node=0x2aaaaf71f050) at eval.c:3955
#26 0x00000000004172ff in rb_eval (self=46912575039840, node=0x2aaaaf71f190) at eval.c:4079
#27 0x0000000000416b6e in rb_eval (self=46912575039840, node=0x2aaaaf71e718) at eval.c:3843
#28 0x0000000000423fd2 in eval_rescue (self=46912575039840, node=0x2aaaaf71e268) at eval.c:3225
#29 0x0000000000417602 in rb_eval (self=46912575039840, node=0x2aaaaf71e268) at eval.c:3976
#30 0x0000000000416035 in rb_yield_0 (val=6, self=46912575039840, klass=0, flags=<value optimized out>, avalue=0)
at eval.c:5218