From: Gabriel Corona Date: Thu, 27 Mar 2014 10:00:11 +0000 (+0100) Subject: [mc] Correctly handle the end of the stack unwinding X-Git-Tag: v3_11~189^2~18 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0f03f9b048ab31cdc19f07738e25264a9710d3dd [mc] Correctly handle the end of the stack unwinding unw_step returns 0 when reaching the bottom of the stack: this return code was not handled correctly leading to infinite loops in some cases. --- diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index cece2e82ad..e482c42aa4 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -323,8 +323,13 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) { unw_cursor_t c; - int ret; - for(ret = unw_init_local(&c, (unw_context_t *)stack_context); ret >= 0; ret = unw_step(&c)){ + // TODO, check condition check (unw_init_local==0 means end of frame) + if(unw_init_local(&c, (unw_context_t *)stack_context)!=0) { + + xbt_die("Could not initialize stack unwinding"); + + } else while(1) { + mc_stack_frame_t stack_frame = xbt_new(s_mc_stack_frame_t, 1); xbt_dynar_push(result, &stack_frame); @@ -348,11 +353,19 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) { stack_frame->frame_base = (unw_word_t)mc_find_frame_base(frame, frame->object_info, &c); } else { stack_frame->frame_base = 0; + stack_frame->frame_name = NULL; } /* Stop before context switch with maestro */ if(frame!=NULL && frame->name!=NULL && !strcmp(frame->name, "smx_ctx_sysv_wrapper")) break; + + int ret = ret = unw_step(&c); + if(ret==0) { + xbt_die("Unexpected end of stack."); + } else if(ret<0) { + xbt_die("Error while unwinding stack."); + } } if(xbt_dynar_length(result) == 0){