lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am having problems with one of the Asserts in the 2.0.2 version of the LuaProfiler code when building it with the DEBUG variable set.  Specifically the ASSERT in ‘lprofM_pause_total_time’:

 

/* pause the total timer for all the functions that are in the stack */

void lprofM_pause_total_time(lprofP_STATE* S) {

  lprofS_STACK aux;

 

  ASSERT(S->stack_top, "pause_total_time: stack_top null");

 

  /* auxiliary stack */

  aux = S->stack_top;

       

  /* pause */

  while (aux) {

    compute_total_time(aux);

    aux = aux->next;

  }

}

 

I have built the LuaProfiler into a static library containing both Lua and LuaProfiler.  If I do so without the DEBUG variable set (e.g. ASSERT is a NOOP) or comment out the ASSERT above the code seems to run OK (and I get valid looking profiler results).  If not then the ASSERT above fails immediately and the application exits.  The function above is called from two places.  The one I am having trouble with is:

 

/* pauses all timers to write a log line and computes the new stack */

/* returns if there is another function in the stack */

int lprofP_callhookOUT(lprofP_STATE* S) {

 

  if (S->stack_level == 0) {

    return 0;

  }

 

  S->stack_level--;

 

  /* 0: do not resume the parent function's timer yet... */

  info = lprofM_leave_function(S, 0);

  /* writing a log may take too long to be computed with the function's time ...*/

  lprofM_pause_total_time(S);

}

 

If the function being exited is at the bottom of the stack (level 1) then in my configuration the ASSERT fails.

 

Note that the ”profM_leave_function” (which is called right before “lprofM_pause_total_time”) has the same ASSERT and is OK, but, after its ASSERT it pops the top value from the stack:

 

lprofS_STACK_RECORD *lprofM_leave_function(lprofP_STATE* S, int isto_resume) {

 

  ASSERT(S->stack_top, "leave_function: stack_top null");

 

  leave_ret = lprofS_pop(&(S->stack_top));

}

 

This would appear to leave nothing in the stack if the function being exited is at the bottom of the stack and therefore trigger the issue I am seeing.

 

My guess is that I am overlooking something.  Can anyone provide some insights into what my problem might be?

 

Regards,

 

Jim