Segfault in timer.rb

Hi Florian,

> Florian Gross wrote:
>> Erlend Oye wrote:
>> /usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark() called for
>> broken object
>> ruby 1.8.2 (2005-01-10) [i386-cygwin]

>> [...]
>> zsh: 22780 abort (core dumped) ruby scrape_server.rb
>> --------
>> /usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark(): unknown data
>> type 0x2e(0x1037d178) non object
>> ruby 1.8.2 (2005-01-10) [i386-cygwin]
>

>Any other libraries that it's using? YAML used to do something similar.

Here are the various requires and includes (not in order)

require 'cgi'
require 'net/http'
require 'rexml/document'
require 'uri/http'
include WEBrick
require 'webrick'

I believe timeout is being used by Webrick internally and not RSSScraper
directly.

RSSScraper is at

http://rssscraper.rubyforge.org

Thanks
Erlend Oye

Erlend Oye wrote:

Hi Florian,

> Florian Gross wrote:
>> Erlend Oye wrote:
>> /usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark() called for
>> broken object
>> ruby 1.8.2 (2005-01-10) [i386-cygwin]

>> [...]
>> zsh: 22780 abort (core dumped) ruby scrape_server.rb
>> --------
>> /usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark(): unknown data
>> type 0x2e(0x1037d178) non object
>> ruby 1.8.2 (2005-01-10) [i386-cygwin]
>

>Any other libraries that it's using? YAML used to do something similar.

Here are the various requires and includes (not in order)

require 'cgi'
require 'net/http'
require 'rexml/document'
require 'uri/http'
include WEBrick
require 'webrick'

I believe timeout is being used by Webrick internally and not RSSScraper
directly.

RSSScraper is at

http://rssscraper.rubyforge.org

Thanks
Erlend Oye

All of these segfaults seemed to be happening at

Thread.start

statements. This hinted some trouble with thread support so I recompiled using

--disable-pthread

and the troubles have disappeared. I wonder if this is an issue from Ruby's side
or on Cygwin's side. I am noticing other segfaults being reported on other platforms
(e.g linux) due to pthreads support also.

Thanks
Erlend Oye

Erlend Oye wrote:

Erlend Oye wrote:

Hi Florian,

Florian Gross wrote:

Erlend Oye wrote:
/usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark() called for
broken object
ruby 1.8.2 (2005-01-10) [i386-cygwin]

[…]
zsh: 22780 abort (core dumped) ruby scrape_server.rb

/usr/local/lib/ruby/1.8/timeout.rb:40: [BUG] rb_gc_mark(): unknown
data
type 0x2e(0x1037d178) non object
ruby 1.8.2 (2005-01-10) [i386-cygwin]

Any other libraries that it’s using? YAML used to do something similar.

Here are the various requires and includes (not in order)

require ‘cgi’
require ‘net/http’
require ‘rexml/document’
require ‘uri/http’
include WEBrick
require ‘webrick’

I believe timeout is being used by Webrick internally and not RSSScraper
directly.

RSSScraper is at

http://rssscraper.rubyforge.org

Thanks
Erlend Oye

All of these segfaults seemed to be happening at

Thread.start

statements. This hinted some trouble with thread support so I
recompiled using

–disable-pthread

and the troubles have disappeared. I wonder if this is an issue from
Ruby’s side
or on Cygwin’s side. I am noticing other segfaults being reported on
other platforms
(e.g linux) due to pthreads support also.

Thanks
Erlend Oye

(Cross posting to core)

Spoke too soon. The segfault still happens at

Thread.start

-Erlend Oye

> and previously without the CFLAGS and
> --disable-pthread
> but got the same segfaults. It always happens in
> Thread.start :confused:

Well, try to write a small script to reproduce the problem. Personnally I
don't have access to a cygwin system, and ruby just work fine.

Guy Decoux

Here's a sample script, which is basically the condensed version of what RSSScraper does

···

---------------------------------
#!/usr/local/bin/ruby
require 'webrick'
require 'open-uri'
include WEBrick

class SegfaultServlet < HTTPServlet::AbstractServlet
  def do_GET(req, res)
    url = req.path.to_s[/.*?\/(.+)/, 1]
    res['Content-Type'] = "text/html"
    res['Url-You-Sent'] = "#{url}"
    STDERR.puts "http://#{url}"
    res.body = open("http://#{url}").read
  end
end
s= HTTPServer.new(:Port => 5363)
s.mount("/", SegfaultServlet)
trap("INT"){ s.shutdown }
s.start
-------------------------------

Run it and use it using some wgets

wget 'http://localhost:5363/slashdot.org&#39; & ; \
  sleep 1 ; \
  wget 'http://localhost:5363/slashdot.org&#39; & ; \
  sleep 1 ; \
  wget 'http://localhost:5363/www.lambda-the-ultimate.org&#39; & ; \
  sleep 1 ; \
  wget 'http://localhost:5363/www.ruby-lang.org&#39;

and sure enough it segfaults, here's another backtrace

% gdb ruby
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
Copyright 2004 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 "i686-pc-cygwin"...
(gdb) run test.rb
Starting program: /usr/local/bin/ruby.exe test.rb

Program received signal SIGSEGV, Segmentation fault.
0x10023952 in cygruby19!Init_load () from /usr/local/bin/cygruby19.dll
(gdb) bt
#0 0x10023952 in cygruby19!Init_load () from /usr/local/bin/cygruby19.dll
#1 0x10023984 in cygruby19!Init_load () from /usr/local/bin/cygruby19.dll
#2 0x10033d76 in rb_gc_force_recycle () from /usr/local/bin/cygruby19.dll
#3 0x100338c4 in rb_gc_mark () from /usr/local/bin/cygruby19.dll
#4 0x10034130 in rb_gc_mark_frame () from /usr/local/bin/cygruby19.dll
#5 0x100327c8 in ruby_xmalloc () from /usr/local/bin/cygruby19.dll
#6 0x1002383d in cygruby19!Init_load () from /usr/local/bin/cygruby19.dll
#7 0x1001f8b2 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#8 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#9 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#10 0x10024fe5 in rb_proc_arity () from /usr/local/bin/cygruby19.dll
#11 0x100187df in rb_alias () from /usr/local/bin/cygruby19.dll
#12 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#13 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#14 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#15 0x100189bb in rb_alias () from /usr/local/bin/cygruby19.dll
#16 0x10018e82 in rb_alias () from /usr/local/bin/cygruby19.dll
#17 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#18 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#19 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#20 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#21 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#22 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#23 0x1001a975 in rb_alias () from /usr/local/bin/cygruby19.dll
#24 0x100185ad in rb_alias () from /usr/local/bin/cygruby19.dll
#25 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#26 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#27 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#28 0x10017e32 in rb_alias () from /usr/local/bin/cygruby19.dll
#29 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#30 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#31 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#32 0x10018e82 in rb_alias () from /usr/local/bin/cygruby19.dll
#33 0x10019083 in rb_alias () from /usr/local/bin/cygruby19.dll
#34 0x10018598 in rb_alias () from /usr/local/bin/cygruby19.dll
#35 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#36 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#37 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#38 0x10018e82 in rb_alias () from /usr/local/bin/cygruby19.dll
#39 0x10019083 in rb_alias () from /usr/local/bin/cygruby19.dll
#40 0x1001d623 in rb_iterator_p () from /usr/local/bin/cygruby19.dll
#41 0x1002a333 in rb_thread_create () from /usr/local/bin/cygruby19.dll
#42 0x1002a041 in rb_thread_group () from /usr/local/bin/cygruby19.dll
#43 0x1002a4a6 in rb_thread_create () from /usr/local/bin/cygruby19.dll
#44 0x1002c2cb in rb_throw () from /usr/local/bin/cygruby19.dll
#45 0x1001f190 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#46 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#47 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#48 0x100189bb in rb_alias () from /usr/local/bin/cygruby19.dll
#49 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#50 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#51 0x10019ce2 in rb_alias () from /usr/local/bin/cygruby19.dll
#52 0x10024eaa in rb_proc_arity () from /usr/local/bin/cygruby19.dll
#53 0x100187df in rb_alias () from /usr/local/bin/cygruby19.dll
#54 0x1001a9e0 in rb_alias () from /usr/local/bin/cygruby19.dll
#55 0x1001d623 in rb_iterator_p () from /usr/local/bin/cygruby19.dll
#56 0x1001da03 in rb_yield () from /usr/local/bin/cygruby19.dll
#57 0x10002aa6 in rb_ary_each () from /usr/local/bin/cygruby19.dll
#58 0x1002c2ff in rb_throw () from /usr/local/bin/cygruby19.dll
#59 0x1001f190 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#60 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#61 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#62 0x100189bb in rb_alias () from /usr/local/bin/cygruby19.dll
#63 0x10018e82 in rb_alias () from /usr/local/bin/cygruby19.dll
#64 0x10018598 in rb_alias () from /usr/local/bin/cygruby19.dll
#65 0x1001d623 in rb_iterator_p () from /usr/local/bin/cygruby19.dll
#66 0x10018ddb in rb_alias () from /usr/local/bin/cygruby19.dll
---Type <return> to continue, or q <return> to quit---
#67 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#68 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#69 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#70 0x100189bb in rb_alias () from /usr/local/bin/cygruby19.dll
#71 0x1001f7b1 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#72 0x1001fcc9 in rb_with_disable_interrupt () from /usr/local/bin/cygruby19.dll
#73 0x10019a5f in rb_alias () from /usr/local/bin/cygruby19.dll
#74 0x100155a3 in ruby_init () from /usr/local/bin/cygruby19.dll
#75 0x10015b34 in ruby_cleanup () from /usr/local/bin/cygruby19.dll
#76 0x10015b6b in ruby_exec () from /usr/local/bin/cygruby19.dll
#77 0x10015ba6 in ruby_run () from /usr/local/bin/cygruby19.dll
#78 0x0040109a in main (argc=2, argv=0x100f2fc8, envp=0x100f00a8) at main.c:38
(gdb)

-Seg Fault/Erlend Oye/Cygwin Supported?

With such a name, ruby can only segfault and it do this just to be
pleasant with you :slight_smile:

Here's a gdb stacktrace

Well, probably it was not compiled with the right option.

With a correct backtrace, probably you'll not see such calls

/usr/local/bin/cygruby19.dll
#40 0x10019a5f in rb_alias () from
/usr/local/bin/cygruby19.dll
#41 0x100189bb in rb_alias () from
/usr/local/bin/cygruby19.dll
#42 0x1001a975 in rb_alias () from
/usr/local/bin/cygruby19.dll
#43 0x10019083 in rb_alias () from
/usr/local/bin/cygruby19.dll

this is probably rb_call() rather than rb_alias() : this means that gdb has
problem to give the correct backtrace

Guy Decoux

Here's a sample script, which is basically the condensed version of what
RSSScraper does

I was unable to reproduce the problem (linux, openbsd, solaris), someone
with cygwin can try this example ?

Guy Decoux