# Help me debug my stack trace

**URL:** <https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071>\
**Category:** Ruby\
**Created:** [May 20, 2008, 12:25am UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071 "2008-05-20T00:25:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 20, 2008, 12:25am UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/1 "2008-05-20T00:25:05Z")

</div>

So currently ruby is hung using 100% CPU on my machine.

Some questions:

1. does anybody else have this happen to them?
2. does anybody else have a chunk of code that reliably causes ruby to  
leak memory?

Anyway here are some sample stack traces, if anybody has any pointers.  
Thanks!  
-R

1 24540 select$UNIX2003:entry  
1 24523 select$DARWIN\_EXTSN:entry  
1 23368 \_sysenter\_trap:entry  
1 22941 ruby\_stack\_length:entry  
1 23392 memcpy:entry  
1 23094 rb\_lastline\_get:entry  
1 22804 rb\_svar:entry  
1 23095 rb\_lastline\_set:entry  
1 22804 rb\_svar:entry  
1 23092 rb\_backref\_get:entry  
1 22804 rb\_svar:entry  
1 23093 rb\_backref\_set:entry  
1 22804 rb\_svar:entry  
1 23991 \_setjmp:entry  
1 23392 memcpy:entry  
1 23094 rb\_lastline\_get:entry  
1 22804 rb\_svar:entry  
1 23095 rb\_lastline\_set:entry  
1 22804 rb\_svar:entry  
1 23092 rb\_backref\_get:entry  
1 22804 rb\_svar:entry  
1 23093 rb\_backref\_set:entry  
1 22804 rb\_svar:entry  
1 23992 \_longjmp:entry  
1 24032 time:entry  
1 28005 fegetenv:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 28000 fesetenv:entry  
1 22874 rb\_thread\_schedule:entry  
1 22806 is\_ruby\_native\_thread:entry  
1 23481 pthread\_self:entry  
1 23868 pthread\_equal:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 24540 select$UNIX2003:entry  
1 24523 select$DARWIN\_EXTSN:entry  
1 23368 \_sysenter\_trap:entry  
1 22943 rb\_gc\_force\_recycle:entry  
1 22871 rb\_need\_block:entry  
1 22960 rb\_newobj:entry  
1 23991 \_setjmp:entry  
1 22749 rb\_scan\_args:entry  
1 22987 rb\_io\_taint\_check:entry  
1 22790 rb\_check\_frozen:entry  
1 23015 rb\_io\_check\_closed:entry  
1 24902 fseeko:entry  
1 23383 \_\_error:entry  
1 24293 flockfile:entry  
1 23481 pthread\_self:entry  
1 23409 pthread\_mutex\_lock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24177 \_fseeko:entry  
1 24180 \_ftello:entry  
1 24155 \_\_sflush:entry  
1 24181 \_sseek:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry

these errors are disconcerting

1 24182 \_\_sseek:entry  
1 23895 lseek:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry  
1 24184 \_\_srefill:entry  
1 24185 \_sread:entry  
1 24186 \_\_sread:entry  
1 23377 read:entry  
1 23368 \_sysenter\_trap:entry  
1 24294 funlockfile:entry  
1 23481 pthread\_self:entry  
1 23410 pthread\_mutex\_unlock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 23383 \_\_error:entry  
1 24919 clearerr:entry  
1 24293 flockfile:entry  
1 23481 pthread\_self:entry  
1 23409 pthread\_mutex\_lock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24294 funlockfile:entry  
1 23481 pthread\_self:entry  
1 23410 pthread\_mutex\_unlock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 22987 rb\_io\_taint\_check:entry  
1 22790 rb\_check\_frozen:entry  
1 23015 rb\_io\_check\_closed:entry  
1 24212 fileno:entry  
1 24293 flockfile:entry  
1 23481 pthread\_self:entry  
1 23409 pthread\_mutex\_lock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24294 funlockfile:entry  
1 23481 pthread\_self:entry  
1 23410 pthread\_mutex\_unlock:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 23887 fstat:entry  
1 23368 \_sysenter\_trap:entry  
1 23242 rb\_time\_new:entry  
1 22962 ruby\_xmalloc:entry  
1 23385 malloc:entry  
1 23386 malloc\_zone\_malloc:entry  
1 23387 szone\_malloc:entry  
1 23471 spin\_lock:entry  
1 23416 tiny\_malloc\_from\_free\_list:entry  
1 23448 tiny\_free\_list\_add\_ptr:entry  
1 23472 \_spin\_unlock:entry  
1 22961 rb\_data\_object\_alloc:entry  
1 22960 rb\_newobj:entry  
1 22788 rb\_check\_type:entry  
1 22788 rb\_check\_type:entry  
1 22867 rb\_funcall:entry  
1 22788 rb\_check\_type:entry  
1 22788 rb\_check\_type:entry  
1 22756 rb\_cmpint:entry  
1 24032 time:entry  
1 28005 fegetenv:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 28000 fesetenv:entry  
1 23244 rb\_time\_interval:entry  
1 22883 rb\_thread\_wait\_for:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 22874 rb\_thread\_schedule:entry  
1 22806 is\_ruby\_native\_thread:entry  
1 23481 pthread\_self:entry  
1 23868 pthread\_equal:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 24540 select$UNIX2003:entry  
1 24523 select$DARWIN\_EXTSN:entry  
1 23368 \_sysenter\_trap:entry  
1 23367 cerror:entry  
1 23382 cthread\_set\_errno\_self:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry

there seem to be some thread problems?

1 23899 pthread\_testcancel$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 23398 nanosleep$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24628 clock\_get\_time:entry  
1 23406 mig\_get\_reply\_port:entry  
1 23407 mach\_msg:entry  
1 23327 mach\_msg\_trap:entry  
1 23368 \_sysenter\_trap:entry  
1 23400 \_\_semwait\_signal:entry  
1 23368 \_sysenter\_trap:entry  
1 23367 cerror:entry  
1 23382 cthread\_set\_errno\_self:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry  
1 23899 pthread\_testcancel$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 23398 nanosleep$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24628 clock\_get\_time:entry  
1 23406 mig\_get\_reply\_port:entry  
1 23407 mach\_msg:entry  
1 23327 mach\_msg\_trap:entry  
1 23368 \_sysenter\_trap:entry  
1 23400 \_\_semwait\_signal:entry  
1 23368 \_sysenter\_trap:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23356 memset:entry  
1 23952 gettimeofday:entry  
1 23953 \_\_commpage\_gettimeofday:entry  
1 24540 select$UNIX2003:entry  
1 24523 select$DARWIN\_EXTSN:entry  
1 23368 \_sysenter\_trap:entry  
1 22941 ruby\_stack\_length:entry  
1 23392 memcpy:entry  
1 23094 rb\_lastline\_get:entry  
1 22804 rb\_svar:entry  
1 23095 rb\_lastline\_set:entry  
1 22804 rb\_svar:entry  
1 23092 rb\_backref\_get:entry  
1 22804 rb\_svar:entry  
1 23093 rb\_backref\_set:entry  
1 22804 rb\_svar:entry  
1 23991 \_setjmp:entry  
1 23392 memcpy:entry  
1 23094 rb\_lastline\_get:entry  
1 22804 rb\_svar:entry  
1 23095 rb\_lastline\_set:entry  
1 22804 rb\_svar:entry  
1 23092 rb\_backref\_get:entry  
1 22804 rb\_svar:entry

…  
but most of the time it loops doing this:  
1 23899 pthread\_testcancel$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 23398 nanosleep$UNIX2003:entry  
1 23399 \_pthread\_testcancel:entry  
1 23471 spin\_lock:entry  
1 23472 \_spin\_unlock:entry  
1 24628 clock\_get\_time:entry  
1 23406 mig\_get\_reply\_port:entry  
1 23407 mach\_msg:entry  
1 23327 mach\_msg\_trap:entry  
1 23368 \_sysenter\_trap:entry  
1 23400 \_\_semwait\_signal:entry  
1 23368 \_sysenter\_trap:entry  
1 23367 cerror:entry  
1 23382 cthread\_set\_errno\_self:entry  
1 23383 \_\_error:entry  
1 23383 \_\_error:entry  
1 23899 pthread\_testcancel$UNIX2003:entry

Oh wait–the problem just resolved itself and ruby has returned to  
running 3% cpu instead of 100. This is bizarre.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 20, 2008, 8:35am UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/2 "2008-05-20T08:35:40Z")

</div>

On 20.05.2008 00:25, Roger P. wrote:

> So currently ruby is hung using 100% CPU on my machine.
> 
> Some questions:
> 
> 1. does anybody else have this happen to them?
> 2. does anybody else have a chunk of code that reliably causes ruby to  
> leak memory?
> 
> Anyway here are some sample stack traces, if anybody has any pointers.  
> Thanks!

You’d probably get more replies if you supply some more environmental  
information like the OS, Ruby version, compiler, Ruby code executed etc.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 20, 2008, 12:25pm UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/3 "2008-05-20T12:25:58Z")

</div>

> On 20.05.2008 00:25, Roger P. wrote:
> 
> > So currently ruby is hung using 100% CPU on my machine.
> 
> > Some questions:
> > 
> > 1. does anybody else have this happen to them?
> > 2. does anybody else have a chunk of code that reliably causes ruby to  
> > leak memory?

It’s more than just possible to write rickety code in Ruby, it’s  
encouraged. If you’ve got a chunk that’s bleeding, let us see.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 20, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/4 "2008-05-20T14:25:05Z")

</div>

Kinda hard to even try help… looks like ancient egypts wrote something  
and you try to translate it without rosetta-stone!

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [June 19, 2008, 4:40am UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/5 "2008-06-19T04:40:33Z")

</div>

Roger P. wrote:

> So currently ruby is hung using 100% CPU on my machine.
> 
> Some questions:
> 
> 1. does anybody else have this happen to them?
> 2. does anybody else have a chunk of code that reliably causes ruby to  
> leak memory?
> 
> Anyway here are some sample stack traces, if anybody has any pointers.  
> Thanks!  
> -R
> 
> 1 24540 select$UNIX2003:entry  
> 1 24523 select$DARWIN\_EXTSN:entry  
> 1 23368 \_sysenter\_trap:entry  
> 1 22941 ruby\_stack\_length:entry  
> 1 23392 memcpy:entry  
> appears that this might be something in common only to mac os 10.5 based  
> on this thread [1]. Apparently it returns a ‘weird’ error message for  
> forcedly closed sockets, so ruby just keeps writing to it and writing to  
> it [trying to] without successfully writing anything [and select fails,  
> etc. etc.]

At least, that’s my hypothesis. Hard to know if we should come up with  
a patch for ruby just to accomodate Leopard. Except that it’s pretty  
common 🙂  
-R

[http://www.nabble.com/RabbitMQ-running-at-100--CPU.-td16024387.html](http://www.nabble.com/RabbitMQ-running-at-100--CPU.-td16024387.html)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 20, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/help-me-debug-my-stack-trace/138071/6 "2008-05-20T21:51:53Z")

</div>

Marc H. wrote:

> Kinda hard to even try help… looks like ancient egypts wrote something  
> and you try to translate it without rosetta-stone!  
> Exactly! 🙂  
> sorry to post without much specs.  
> This is OS X 5.1 and Ruby 1.8.6 patchlevel 111 running what seems to be  
> a ‘normal’ rails app and it just started sky-rocketing cpu between  
> requests and wouldn’t answer requests for awhile.  
> Now that I think of it, though, I wonder if the patchlevel 11 is the  
> culprit. I’ll upgrade and see if the problem occurs again.  
> Thanks!  
> -R
