Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ruby-debug say 'Saved frames may be incomplete'

From time-to-time I get this when a breakpoint is triggered. It looks like stack frames aren't getting saved so I can't step back through the call stack - a real pain. See below for an example

--> #0 BatchProcess.add_failure_record(row_id#Fixnum, test#Struct::Test, message#String,...) 
       at line server/processes/batch.rb:309
Warning: saved frames may be incomplete; compare with caller(0).
(rdb:1) pp caller
["./server/processes/batch.rb:309:in `run_tests'",
 "./server/processes/common/generic_process.rb:219:in `each'",
 "./server/processes/common/generic_process.rb:219:in `run_tests'",
 "./server/processes/common/generic_process.rb:271:in `run_plan'",
 "./server/processes/common/corrections.rb:19:in `each_with_index'",
 "./server/processes/common/generic_process.rb:266:in `each'",
 "./server/processes/common/generic_process.rb:266:in `each_with_index'",
 "./server/processes/common/generic_process.rb:266:in `run_plan'",
 "./server/processes/batch.rb:202:in `run_engine'",
 "/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'",
 "./server/processes/batch.rb:201:in `run_engine'",
 "./server/processes/common/generic_process.rb:88:in `run_dataset'",
 "./server/processes/batch.rb:210:in `run_dataset'",
 "/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'",
 "./server/processes/batch.rb:209:in `run_dataset'",
 "./server/processes/common/generic_process.rb:159:in `run'",
 "./server/processes/common/generic_process.rb:158:in `each'",
 "./server/processes/common/generic_process.rb:158:in `run'",
 "./server/processes/batch.rb:350:in `run'",
 "/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'",
 "./server/processes/batch.rb:349:in `run'",
 "server/processes/test_runs/run_tests.rb:55:in `run_one_process'",
 "server/processes/test_runs/run_tests.rb:81"]

Any ideas on how to stop this happening?

like image 685
Chris McCauley Avatar asked May 04 '10 08:05

Chris McCauley


1 Answers

It means the call stack as reported by Ruby's caller() function doesn't match what the debugger has recorded as the call stack.

This can happen if the debugger tracking was activated while the call stack had more than one frame in it. It can also happen as a result of a bug in ruby-debug where it isn't tracking correctly. One "remedy" is to put this in at the very beginning of the file in main file: require 'ruby-debug'; Debugger.start

However the downside of this is that there is some additional overhead added right from the beginning of the program.

Somewhere in your Ruby code you have to tell Ruby to start tracking calls and returns. Typically this is done via combination of Debugger.start and Debugger.stop or Debugger.start { }. If you are running from a framework, these commands are issued somewhere for you, so the responsibility of issuing at the right place rests on the programmer who added this code.

Finally, down the line I will change the message to be a little more explicit:

Warning: saved frames may be incomplete; 
compare debugger backtrace (bt) with Ruby caller(0).
like image 114
Rocky Bernstein Avatar answered Oct 25 '22 01:10

Rocky Bernstein