Skip to content

Instantly share code, notes, and snippets.

@ianpetzer
Created August 24, 2012 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianpetzer/3448744 to your computer and use it in GitHub Desktop.
Save ianpetzer/3448744 to your computer and use it in GitHub Desktop.
Output when trying to use gdb_ruby to debug cpu consuming threads
I used the ruby_gbd macros found at:
https://github.com/pusewicz/ruby-gdb
then ran:
sudo gdb /path/to/ruby PID
In gdb: I attempted to run the following commands
session-ruby
redirect_stdout # redirects gdb output to /tmp/ruby-debug.PID eval "caller" # dumps backtrace
However when I attempted to redirect the thread output to std_out, it appeared to kill the thread, as I couldn't run veal 'caller' afterwards.
There was no output in /tmp/ruby-debug.12840 (the file didn't exist) However I did find this in the Apache error_log . This entry refers to the thread that I attempted to debug (PID = 12840)… However I'm not sure if this error refers to what the thread was doing or the problem that was encountered when I attempted to redirect the std_out
[ pid=12840 thr=74951720 file=utils.rb:176 time=2012-08-23 14:55:27.145 ]: *** Exception NoMethodError in application (private method `open' called for Rack::File:Class) (process 12840, thread #<Thread:0x8ef5850>):
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:129:in `=~'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:129:in `=~'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:129:in `get_filename'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:102:in `get_current_head_and_filename_and_content_type_and_name_and_body'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:22:in `block in parse'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:20:in `loop'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart/parser.rb:20:in `parse'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/multipart.rb:25:in `parse_multipart'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/request.rb:306:in `parse_multipart'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/request.rb:182:in `POST'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/methodoverride.rb:15:in `call'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/runtime.rb:17:in `call'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/lock.rb:15:in `call'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
from /var/www/rails/portal-business/shared/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:205:in `start_request_handler'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/utils.rb:479:in `safe_fork'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
from <internal:prelude>:10:in `synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server:99:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment