[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: again and again and again
Hi Mark,
How sure are you that the infinite loop is originating in that
thread? In particular, that code is from the "main" thread which
basically sleeps and then wakes up to check if everything is done and
report the rate etc. In other words, it is designed to be an "infinite
loop" that mostly sleeps. There should be at least 2 other threads
existing. One is the event reader thread and the other is the event
processor thread (assuming you're using only 1). Usually, the culprit is
the event processing loop. That can be identified by a JEventLoop method
call somewhere in the backtrace or more easily "LaunchThread" at the top
of the backtrace.
Regards,
-David
Mark M. Ito wrote:
> Folks,
>
> Help! I'm in a loop!
>
> My fitting program occasionally goes into an infinite loop at present.
> When I run it under the debugger and it has fallen into the loop and I
> control-C it and backtrace it, it wakes up in JApplication.cc. Here
> are the statements that are getting repeated:
>
> 957 do{
> 960 rem.tv_sec = rem.tv_nsec = 0;
> 961 nanosleep(&req, &rem);
> 962 if(rem.tv_sec == 0 && rem.tv_nsec == 0){
> 965 int delta_NEvents = NEvents -
> GetEventBufferSize() - last_NEvents;
> 966 avg_NEvents += delta_NEvents>0 ?
> delta_NEvents:0;
> 967 avg_time += sleep_time;
> 968 rate_instantaneous =
> (double)delta_NEvents/sleep_time;
> 969 rate_average =
> (double)avg_NEvents/avg_time;
> 973 last_NEvents = NEvents - GetEventBufferSize();
> 976 if(show_ticker && loops.size()>0)PrintRate();
> 978 if(SIGINT_RECEIVED)Quit();
> 979 if(SIGINT_RECEIVED>=3)break;
> 983 pthread_mutex_lock(&app_mutex);
> 986 double rem_time = (double)rem.tv_sec +
> (1.0E-9)*(double)rem.tv_nsec;
> 987 double slept_time = sleep_time - rem_time;
> 988 for(unsigned int i=0;i<heartbeats.size();i++){
> 989 double *hb = heartbeats[i];
> 990 *hb += slept_time;
> 991 if(monitor_heartbeat && (*hb >
> (THREAD_TIMEOUT-1.0)+sleep_time)){
> 988 for(unsigned int i=0;i<heartbeats.size();i++){
> 1042 pthread_mutex_unlock(&app_mutex);
> 957 do{
>
> and so forth.
>
> Is there any wisdom about what may have caused it? I'm not even sure
> that the above mentioned loop is the one that is causing problems.
> Probably some random memory overwrite on my part, but there may be
> hints for finding it out there, something of which I am unaware.
>
> -- Mark
>
--
------------------------------------------------------------------------
David Lawrence Ph.D.
Staff Scientist Office: (757)269-5567 [[[ [ [ [
Jefferson Lab Pager: (757)584-5567 [ [ [ [ [ [
http://www.jlab.org/~davidl davidl@jlab.org [[[ [[ [[ [[[
------------------------------------------------------------------------