From: mquinson Date: Tue, 11 Apr 2006 11:58:42 +0000 (+0000) Subject: only dupplicate the procname when dealing with remote processes; cleanup the free... X-Git-Tag: v3.3~3243 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3c0619f4774180c94441d53b01f34257ad0853fa only dupplicate the procname when dealing with remote processes; cleanup the free function so that things won't get reused from one time to the other (since it causes bad segfaults); and make the testcase a bit stricter git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2115 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/ex.c b/src/xbt/ex.c index 7c4b18fa1a..8d1cba1bef 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -152,19 +152,19 @@ void xbt_ex_free(xbt_ex_t *e) { int i; if (e->msg) free(e->msg); - free(e->procname); if (e->remote) { + free(e->procname); free(e->file); free(e->func); free(e->host); } + if (e->bt_strings) { for (i=0; iused; i++) - free(e->bt_strings[i]); - free(e->bt_strings); - e->bt_strings = NULL; + free((char*)e->bt_strings[i]); + free((char **)e->bt_strings); } - + memset(e,0,sizeof(xbt_ex_t)); } /** \brief returns a short name for the given exception category */ @@ -212,20 +212,33 @@ XBT_TEST_UNIT("controlflow",test_controlflow, "basic nested control flow") { THROW0(unknown_error,0,"something"); } CATCH (ex) { if (n != 3) - xbt_test_fail1("M3: n=%d (!= 1)", n); + xbt_test_fail1("M3: n=%d (!= 3)", n); + n++; + xbt_ex_free(&ex); + } + n++; + TRY { + if (n != 5) + xbt_test_fail1("M2: n=%d (!= 5)", n); + n++; + THROW0(unknown_error,0,"something"); + } CATCH (ex) { + if (n != 6) + xbt_test_fail1("M3: n=%d (!= 6)", n); n++; RETHROW; + n++; } xbt_test_fail1("MX: n=%d (shouldn't reach this point)", n); } CATCH(ex) { - if (n != 4) - xbt_test_fail1("M4: n=%d (!= 4)", n); + if (n != 7) + xbt_test_fail1("M4: n=%d (!= 7)", n); n++; xbt_ex_free(&ex); } - if (n != 5) - xbt_test_fail1("M5: n=%d (!= 5)", n); + if (n != 8) + xbt_test_fail1("M5: n=%d (!= 8)", n); } XBT_TEST_UNIT("value",test_value,"exception value passing") {