From: Bezan Kapadia Date: 2009-02-16T05:55:43+09:00 Subject: Re: Got SystemStackError exception: stack level too deep Ok .. Well I tested the Code again. This Time the code errored out after 40 hrs with only the System Stack error. Some things I have noted this time.. _________________________________________________ 1)This is how my child process code that runs in the background looks like - The code is precisely doing what Tony has indicated above that could be possibly triggering the Stack error exception. #Main Program def check_for_running_jobs begin # do a whole lot of work rescue Exception => e $mes_trace.error("In MES_monitor check_for_running_jobs : Got #{e.class} exception: #{e.message}") puts "Got #{e.class} exception: #{e.message}" $mes_trace.error(e.backtrace.join("\n")) puts e.backtrace.join("\n") end end def run_function #this function internally calls tons of XYZ functions... check_for_running_jobs # there are rescue statements in various of these XYZ functions to trap exceptions.... sleep(60) #note it gets activated every 60 seconds run_function end run_function ################################### One thing I wanted to know that if I have an exception in some function (run_function and if I rescue that exception in the function (run_function or within other functions that this function calls) ...does that restart execution of the entire program again (note am not doing anything like calling some other method or anything else except rescuing the error)....leading to stack error.. _______________________________________________ 2) Just a Side Note - Am trying to run this background child process for days / may be even weeks something like a cron job that sleeps , wakes up, polls the status and goes to sleep. Is it robust way to Run a detached child process in the background for weeks ...? ______________________________________________ 3) Ok I have got hold of my backtrace if you folks want to take closer look... I, [06:12:05#22059] INFO -- : Sleeping for 2 Minutes I, [06:13:05#22059] INFO -- : Finished Sleeping for 2 Minutes E, [06:13:05#22059] ERROR -- : In MES_monitor check_for_running_jobs : Got SystemStackError exception: stack level too deep E, [06:13:05#22059] ERROR -- : /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/monitor.rb:273:in `mon_check_owner' /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/monitor.rb:220:in `mon_exit' /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/monitor.rb:240:in `synchronize' /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/logger.rb:496:in `write' /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/logger.rb:326:in `add' /usr/pkgs/ruby/1.8.5-p12/lib/ruby/1.8/logger.rb:374:in `info' ./MES_monitor.rb:90:in `check_for_running_jobs' ./MES_monitor.rb:78:in `times' ./MES_monitor.rb:78:in `check_for_running_jobs' ./MES_monitor.rb:70:in `each' ./MES_monitor.rb:70:in `check_for_running_jobs' ./MES_monitor.rb:272:in `run_function' ./MES_monitor.rb:281:in `run_function' ./MES_monitor.rb:283 _________________________________________________ 4) Jayce from what you suggested ... #Main program def run_function #this function internally calls tons of XYZ functions... check_for_running_jobs # there are rescue statements in various of these XYZ functions to trap exceptions.... sleep(60) #note it gets activated every 60 seconds run_function end begin run_function rescue Exception => e $mes_trace.error("In MES_monitor check_for_running_jobs : Got #{e.class} exception: #{e.message}") puts "Got #{e.class} exception: #{e.message}" $mes_trace.error(e.backtrace.join("\n")) puts e.backtrace.join("\n") end Am going to fire test run with the above change...Hopefully this will solve my problem ... let me know if you folks suggest anything else.... __________________________________________ -- Posted via http://www.ruby-forum.com/.