Segmentation faults occur when profiling Rails 3 controller actions that add new objects to the database using Ruby 1.9.2 and ruby-prof.
EXPECTED BEHAVIOR
ruby-prof profile of controller action produced without issue.
ACTUAL BEHAVIOR
Ruby terminates with a segmentation fault during execution of controller action.
TROUBLESHOOTING/REDUCTION
Created new, empty Rails 3.0.3 project. Added one resource with no attributes, methods. Added profiling of 1000 creates of the resource in ItemsController#index action.
Ran "rails server" using Ruby 1.9.2 p0. Loaded http://localhost:3000/items in browser. Server crashed with segmentation fault.
Ran "rails server" using Ruby 1.8.7 p302. Loaded same URI. Action executed without issue.
Repeated this test under different OS using same project files and Ruby 1.9.2 p0. Issue persisted.
Segmentation faults occur when profiling Rails 3 controller actions that add new objects to the database using Ruby 1.9.2 and ruby-prof.
EXPECTED BEHAVIOR
ruby-prof profile of controller action produced without issue.
ACTUAL BEHAVIOR
Ruby terminates with a segmentation fault during execution of controller action.
TROUBLESHOOTING/REDUCTION
Created new, empty Rails 3.0.3 project. Added one resource with no attributes, methods. Added profiling of 1000 creates of the resource in ItemsController#index action.
Ran "rails server" using Ruby 1.9.2 p0. Loaded http://localhost:3000/items in browser. Server crashed with segmentation fault.
Ran "rails server" using Ruby 1.8.7 p302. Loaded same URI. Action executed without issue.
Repeated this test under different OS using same project files and Ruby 1.9.2 p0. Issue persisted.
Issue persists on ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0].
This is an issue with ruby-prof, not Rails or Ruby itself. I've had
segfaults with ruby-prof running against YARD a few weeks back, so this
is likely just a third-party issue.
FWIW, Ruby 1.9.x has a Profiler class that is admittedly slow, but might
be able to stand in for the time being.
=begin
It's certainly not a perfect 1.9 implementation, but profiling on JRuby's 1.9 mode using --profile or --profile.graph (or the jruby-prof gem) may also be a fine stand-in for now. The profiling boundaries are similar to ruby-prof, and may reveal the same bottlenecks as running under Ruby 1.9.
Of course, there are other challenges to "just run it" on JRuby...
=end
...
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 70350]
exec_event_hooks [inlined] () at /Users/evan/.rvm/src/ruby-1.9.2-p136/thread.c:3778
3778 if (flag & hook->flag) {
(gdb) whe
#0 exec_event_hooks [inlined] () at /Users/evan/.rvm/src/ruby-1.9.2-p136/thread.c:3778
...