# Backtrace hopping between threads?

**URL:** <https://www.ruby-forum.com/t/backtrace-hopping-between-threads/186938>\
**Category:** Ruby\
**Created:** [April 14, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/backtrace-hopping-between-threads/186938 "2010-04-14T16:58:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [April 14, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/backtrace-hopping-between-threads/186938/1 "2010-04-14T16:58:14Z")

</div>

Hello, I just got this backtrace and don’t understand something about  
it:

F, [2010-04-14T14:19:11.039347 #28597] FATAL – : can’t clone NilClass  
(SystemExit)  
/usr/lib/ruby/1.8/rexml/text.rb:311:in `recvfrom' /usr/lib/mauvealert/lib/mauve/server.rb:158:in`receive\_waiting\_packets’  
/usr/lib/mauvealert/lib/mauve/server.rb:104:in `run' /usr/lib/mauvealert/lib/mauve/server.rb:91:in`loop’  
/usr/lib/mauvealert/lib/mauve/server.rb:91:in `run' /usr/lib/mauvealert/bin/mauveserver:32 /usr/lib/mauvealert/bin/mauveserver:30:in`loop’  
/usr/lib/mauvealert/bin/mauveserver:30  
/usr/lib/mauvealert/mauve\_starter.rb:22:in `load’  
/usr/lib/mauvealert/mauve\_starter.rb:22

Rather, I understand the exception, the line in server.rb:158 is this:

```
      packets = [@socket.recvfrom(65535)]

```

@socket is just a UDPServer socket, and I’m wanting to read raw data.  
So I don’t understand how the backtrace includes a call to REXML.

Another Thread in the program is processing XMPP messages, that’s the  
only code path that would use REXML, so I assume there is a bug in that  
part of the code, somehow the backtrace pops out in another Thread, and  
I’ve lost the original context.

I don’t have Thread.abort\_on\_exception set.

Is this a backtrace that appears to “cross threads” or is there some  
legitimate reason a socket I/O call could call REXML? This is on  
Debian/lenny’s ruby, 1.8.7 (2009-06-12 patchlevel 174) [x86\_64-linux].

---

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [April 15, 2010, 10:26pm UTC](https://www.ruby-forum.com/t/backtrace-hopping-between-threads/186938/2 "2010-04-15T22:26:48Z")

</div>

> F, [2010-04-14T14:19:11.039347 #28597] FATAL – : can’t clone NilClass  
> (SystemExit)  
> /usr/lib/ruby/1.8/rexml/text.rb:311:in `recvfrom’  
> …  
> Another Thread in the program is processing XMPP messages, that’s the  
> only code path that would use REXML, so I assume there is a bug in that  
> part of the code, somehow the backtrace pops out in another Thread, and  
> I’ve lost the original context.
> 
> I don’t have Thread.abort\_on\_exception set.
> 
> Is this a backtrace that appears to “cross threads” or is there some  
> legitimate reason a socket I/O call could call REXML? This is on  
> Debian/lenny’s ruby, 1.8.7 (2009-06-12 patchlevel 174) [x86\_64-linux].

In Ruby, if the main thread exits “the whole program exits”  
before “the whole program exits”, though, it raises this exception on  
each still running thread. Kind of like “get ready to die.”  
I think that’s the way it is, anyway, and I’m pretty sure the program  
still terminates if the threads rescue that exception, which makes me  
wonder how that all works exactly, but HTH.  
-rp

---

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [April 16, 2010, 10:59am UTC](https://www.ruby-forum.com/t/backtrace-hopping-between-threads/186938/3 "2010-04-16T10:59:15Z")

</div>

On Fri, 2010-04-16 at 05:26 +0900, Roger P. wrote:

> [snip]
> 
> In Ruby, if the main thread exits “the whole program exits”  
> before “the whole program exits”, though, it raises this exception on  
> each still running thread. Kind of like “get ready to die.”  
> I think that’s the way it is, anyway, and I’m pretty sure the program  
> still terminates if the threads rescue that exception, which makes me  
> wonder how that all works exactly, but HTH.

Thanks, I will try some experiments to see if I can get it to behave  
that way again.
