# DTrace segfaults on Leopard

**URL:** <https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393>\
**Category:** Ruby\
**Created:** [January 17, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393 "2008-01-17T23:10:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 17, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/1 "2008-01-17T23:10:56Z")

</div>

I’d like to use DTrace on Leopard to do some profiling of a Ruby app  
but I’m finding that any script that uses the “object-free” probe  
eventually leads to a segfault.

For example, the script that Apple provides at:

/Developer/Examples/Ruby/DTrace/print\_memory\_usage.d

To reproduce:

1. In one Terminal fire up an instance of irb so that dtrace can find  
the probes

2. In another:

sudo dtrace -qs /Developer/Examples/Ruby/DTrace/print\_memory\_usage.d

1. In another, run any sizeable Ruby script and watch the crashes  
ensue.

For example:

# won’t crash

ruby -e ‘1000.times{1+2}’

# will crash

ruby -e ‘10000.times{1+2}’

# will crash

irb

Here’s the console output for the irb crash:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
1.8/irb/extend-command.rb:93: [BUG] Segmentation fault  
ruby 1.8.6 (2007-06-07) [universal-darwin9.0]

Abort trap

And here’s the stack trace:

Exception Type: EXC\_BAD\_ACCESS (SIGABRT)  
Exception Codes: KERN\_INVALID\_ADDRESS at 0x000000007262694c  
Crashed Thread: 0

Thread 0 Crashed:  
0 libSystem.B.dylib 0x92d7f47a \_\_kill + 10  
1 libSystem.B.dylib 0x92df6782 raise + 26  
2 libSystem.B.dylib 0x92e05d3f abort + 73  
3 libruby.1.dylib 0x000cdcbc rb\_exc\_new + 0  
4 libruby.1.dylib 0x001346f3 rb\_gc\_mark\_trap\_list +  
508  
5 libSystem.B.dylib 0x92d7d97b \_sigtramp + 43  
6 ??? 0xffffffff 0 + 4294967295  
7 libruby.1.dylib 0x00144c08 rb\_mod\_class\_variables +  
634  
8 libruby.1.dylib 0x00145680 rb\_class\_path + 31  
9 libruby.1.dylib 0x001458a8 rb\_obj\_classname + 91  
10 libruby.1.dylib 0x000eddbb rb\_gc\_mark\_maybe + 1394  
11 libruby.1.dylib 0x000ee493 rb\_newobj + 28  
12 libruby.1.dylib 0x0010af8f rb\_node\_newnode + 28  
13 libruby.1.dylib 0x0011c881 ruby\_yyparse + 53250  
14 libruby.1.dylib 0x0011dda2 ruby\_yyparse + 58659  
15 libruby.1.dylib 0x00134271 ruby\_process\_options +  
1148  
16 libruby.1.dylib 0x000e69dd rb\_load + 847  
17 libruby.1.dylib 0x000e70a8 rb\_require\_safe + 1117  
18 libruby.1.dylib 0x000da636 rb\_eval\_string\_wrap +  
17759  
19 libruby.1.dylib 0x000db24a rb\_eval\_string\_wrap +  
20851  
20 libruby.1.dylib 0x000d84c5 rb\_eval\_string\_wrap +  
9198  
21 libruby.1.dylib 0x000e6a47 rb\_load + 953  
22 libruby.1.dylib 0x000e70a8 rb\_require\_safe + 1117  
23 libruby.1.dylib 0x000da636 rb\_eval\_string\_wrap +  
17759  
24 libruby.1.dylib 0x000db24a rb\_eval\_string\_wrap +  
20851  
25 libruby.1.dylib 0x000d84c5 rb\_eval\_string\_wrap +  
9198  
26 libruby.1.dylib 0x000e7388 rb\_load\_protect + 298  
27 libruby.1.dylib 0x000e73b9 ruby\_exec + 22  
28 libruby.1.dylib 0x000e73e5 ruby\_run + 42  
29 ruby 0x00001fff 0x1000 + 4095  
30 ruby 0x00001fa6 start + 54

Needless to say, I can’t run the application that I’d like to profile  
either. The same crashes occur when trying to use the “object-free”  
probe from inside Apple’s Instruments GUI.

Can anybody else repro this or is there something fishy with my  
system?

Cheers,  
Wincent

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 24, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/2 "2008-01-24T16:27:10Z")

</div>

I have just read this article, maybe could help you.  
Apple Crippled Its DTrace Port:

> **[Apple Crippled Its DTrace Port - Slashdot](https://developers.slashdot.org/story/08/01/22/2156244/apple-crippled-its-dtrace-port)**
>
> Linnen writes in to note that one of developers of Sun's open source system tracing tool, DTrace, has discovered that Apple crippled its port of the tool so that software like iTunes could not be traced. From Adam Leventhal's blog: "I let it run for...

Juan MatÃ­as Repetti.

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 24, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/3 "2008-01-24T16:13:36Z")

</div>

On Jan 17, 2008, at 2:09 PM, Wincent C. wrote:

> I’d like to use DTrace on Leopard to do some profiling of a Ruby app  
> but I’m finding that any script that uses the “object-free” probe  
> eventually leads to a segfault.

[snip]

> Needless to say, I can’t run the application that I’d like to profile  
> either. The same crashes occur when trying to use the “object-free”  
> probe from inside Apple’s Instruments GUI.
> 
> Can anybody else repro this or is there something fishy with my  
> system?
> 
> Cheers,  
> Wincent

I can reproduce it every time. Happens without fail.

Kind of makes it useless for watching object creation and deletion,  
huh? 🙂

Have you had any luck getting it to work?

-Dane

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 25, 2008, 11:22am UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/4 "2008-01-25T11:22:02Z")

</div>

As far as I recall, I never got dtrace to work with irb at all. I’ll  
check when I get a chance. Anyone else have problems with irb?  
-tim

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 24, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/5 "2008-01-24T21:27:39Z")

</div>

On Jan 24, 2008 10:26 AM, Juan MatÃ­as [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > Can anybody else repro this or is there something fishy with my  
> > > Have you had any luck getting it to work?
> > 
> > -Dane

Apple’s modifications to DTrace aren’t the issue here - it’s a bug in  
the  
Ruby patch, which would be my fault. I can reproduce it and I’m looking  
into a fix. I can release a new ruby patch with the fix but I’ll have  
to  
defer to the Apple guys to see how they want to handle OSX’s ruby.

-Scott

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 25, 2008, 1:07pm UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/6 "2008-01-25T13:07:18Z")

</div>

On Jan 24, 2008 9:25 PM, Scott B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Apple’s modifications to DTrace aren’t the issue here - it’s a bug in the  
> Ruby patch, which would be my fault. I can reproduce it and I’m looking  
> into a fix. I can release a new ruby patch with the fix but I’ll have to  
> defer to the Apple guys to see how they want to handle OSX’s ruby.

Yeah it seems to be a problem with the interpreter patch. I thought  
that these crashes were ppc-only but apparently they also reproduce on  
i386.

If you can fix it please let me know and I will do the necessary  
procedure to also update Leopard’s ruby.

Laurent

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [January 6, 2009, 7:48am UTC](https://www.ruby-forum.com/t/dtrace-segfaults-on-leopard/126393/7 "2009-01-06T07:48:02Z")

</div>

> Apple’s modifications to DTrace aren’t the issue here - it’s a bug in  
> the  
> Ruby patch, which would be my fault. I can reproduce it and I’m looking  
> into a fix. I can release a new ruby patch with the fix but I’ll have  
> to  
> defer to the Apple guys to see how they want to handle OSX’s ruby.
> 
> -Scott

Any update on this? I’m still seeing this on OSX 10.5.6…
