# Segfault in timer.rb

**URL:** <https://rubytalk.org/t/segfault-in-timer-rb/15734>\
**Category:** ruby-talk\
**Created:** [11 January 2005 17:51 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734 "2005-01-11T17:51:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erlend\_Oye](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Erlend\_Oye](https://rubytalk.org/u/Erlend_Oye)\
**Post date:** [11 January 2005 17:51 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/1 "2005-01-11T17:51:19Z")

</div>

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](http://rssscraper.rubyforge.org)

Thanks  
Erlend Oye

---

<div class="post-metadata">

**Author:** ![Erlend\_Oye](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Erlend\_Oye](https://rubytalk.org/u/Erlend_Oye)\
**Post date:** [13 January 2005 06:34 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/2 "2005-01-13T06:34:36Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Erlend\_Oye](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Erlend\_Oye](https://rubytalk.org/u/Erlend_Oye)\
**Post date:** [13 January 2005 16:18 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/3 "2005-01-13T16:18:29Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Seg\_Fault](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Seg\_Fault](https://rubytalk.org/u/Seg_Fault)\
**Post date:** [13 January 2005 18:08 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/4 "2005-01-13T18:08:45Z")

</div>



---

<div class="post-metadata">

**Author:** ![Erlend\_Oye](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Erlend\_Oye](https://rubytalk.org/u/Erlend_Oye)\
**Post date:** [15 January 2005 17:51 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/5 "2005-01-15T17:51:57Z")

</div>

> \> and previously without the CFLAGS and  
> \> --disable-pthread  
> \> but got the same segfaults. It always happens in  
> \> Thread.start 😕
> 
> 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  
> &nbsp;&nbsp;def do\_GET(req, res)  
> &nbsp;&nbsp;&nbsp;&nbsp;url = req.path.to\_s[/.\*?\/(.+)/, 1]  
> &nbsp;&nbsp;&nbsp;&nbsp;res['Content-Type'] = "text/html"  
> &nbsp;&nbsp;&nbsp;&nbsp;res['Url-You-Sent'] = "#{url}"  
> &nbsp;&nbsp;&nbsp;&nbsp;STDERR.puts "http://#{url}"  
> &nbsp;&nbsp;&nbsp;&nbsp;res.body = open("http://#{url}").read  
> &nbsp;&nbsp;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](http://localhost:5363/slashdot.org&#39); & ; \  
> &nbsp;&nbsp;sleep 1 ; \  
> &nbsp;&nbsp;wget '[http://localhost:5363/slashdot.org&#39](http://localhost:5363/slashdot.org&#39); & ; \  
> &nbsp;&nbsp;sleep 1 ; \  
> &nbsp;&nbsp;wget '[http://localhost:5363/www.lambda-the-ultimate.org&#39](http://localhost:5363/www.lambda-the-ultimate.org&#39); & ; \  
> &nbsp;&nbsp;sleep 1 ; \  
> &nbsp;&nbsp;wget '[http://localhost:5363/www.ruby-lang.org&#39](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?

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [13 January 2005 18:32 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/6 "2005-01-13T18:32:41Z")

</div>

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

> 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

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [16 January 2005 11:45 UTC](https://rubytalk.org/t/segfault-in-timer-rb/15734/7 "2005-01-16T11:45:41Z")

</div>

> 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
