From: degomme Date: Fri, 31 Oct 2014 10:28:09 +0000 (+0100) Subject: provide user-friendly errors when replay encounters a badly formatted line. X-Git-Tag: v3_12~732^2~270 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c02a43b1296b3a4be2c40476699f4fd29e75628b?ds=sidebyside provide user-friendly errors when replay encounters a badly formatted line. Avoids segfaults in this case --- diff --git a/src/smpi/smpi_replay.c b/src/smpi/smpi_replay.c index 0dc2d78f3c..09c5b6be1c 100644 --- a/src/smpi/smpi_replay.c +++ b/src/smpi/smpi_replay.c @@ -129,11 +129,23 @@ const char* encode_datatype(MPI_Datatype datatype) return "-1"; } +#define CHECK_ACTION_PARAMS(action, mandatory, optional) {\ + int i=0;\ + while(action[i]!=NULL)\ + i++;\ + if(irecv_size= recvcount; extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); - extra->num_processes = comm_size; + extra->num_processes = smpi_comm_size(MPI_COMM_WORLD); TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif @@ -920,6 +947,7 @@ static void action_allgatherv(const char *const *action) { double clock = smpi_process_simulated_elapsed(); int comm_size = smpi_comm_size(MPI_COMM_WORLD); + CHECK_ACTION_PARAMS(action, comm_size+1, 2); int i=0; int sendcount=atoi(action[2]); int *recvcounts = xbt_new0(int, comm_size); @@ -986,6 +1014,7 @@ static void action_allToAllv(const char *const *action) { double clock = smpi_process_simulated_elapsed(); int comm_size = smpi_comm_size(MPI_COMM_WORLD); + CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2); int send_buf_size=0,recv_buf_size=0,i=0; int *sendcounts = xbt_new0(int, comm_size); int *recvcounts = xbt_new0(int, comm_size); diff --git a/src/xbt/xbt_replay.c b/src/xbt/xbt_replay.c index 7cc39e4286..39bd9523f4 100644 --- a/src/xbt/xbt_replay.c +++ b/src/xbt/xbt_replay.c @@ -20,7 +20,8 @@ typedef struct s_replay_reader { char *line; size_t line_len; char *position; /* stable storage */ - char *filename; int linenum; + char *filename; + int linenum; } s_xbt_replay_reader_t; FILE *action_fp; @@ -154,6 +155,7 @@ void _xbt_replay_action_exit(void) int xbt_replay_action_runner(int argc, char *argv[]) { int i; + xbt_ex_t e; if (action_fp) { // A unique trace file char **evt; while ((evt = action_get_action(argv[0]))) { @@ -161,7 +163,15 @@ int xbt_replay_action_runner(int argc, char *argv[]) action_fun function = (action_fun)xbt_dict_get(action_funs, lowername); xbt_free(lowername); - function((const char **)evt); + TRY{ + function((const char **)evt); + } + CATCH(e) { + XBT_ERROR("Replay error :\n %s" + , e.msg); + xbt_ex_free(e); + RETHROW; + } for (i=0;evt[i]!= NULL;i++) free(evt[i]); free(evt); @@ -179,7 +189,14 @@ int xbt_replay_action_runner(int argc, char *argv[]) char* lowername = str_tolower (evt[1]); action_fun function = (action_fun)xbt_dict_get(action_funs, lowername); xbt_free(lowername); - function(evt); + TRY{ + function(evt); + } + CATCH(e) { + free(evt); + xbt_die("Replay error on line %d of file %s :\n %s" + , reader->linenum,reader->filename, e.msg); + } } else { XBT_WARN("%s: Ignore trace element not for me", xbt_replay_reader_position(reader));