From: mquinson Date: Sat, 27 Oct 2007 11:06:55 +0000 (+0000) Subject: Avoid segfault when trying to retrieve the name of the current thread while being... X-Git-Tag: v3.3~897 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/412030f2d029818ada64567bd92cbc3d0ec0d634 Avoid segfault when trying to retrieve the name of the current thread while being in the maestro before initialization (where SIMIX_process_self returns NULL) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4905 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/xbt_sg_synchro.c b/src/xbt/xbt_sg_synchro.c index 306436d45c..423161fe08 100644 --- a/src/xbt/xbt_sg_synchro.c +++ b/src/xbt/xbt_sg_synchro.c @@ -25,7 +25,7 @@ typedef struct s_xbt_thread_ { smx_process_t s_process; void_f_pvoid_t code; void *userparam; - void *father_data; + void *father_data; } s_xbt_thread_t; static int xbt_thread_create_wrapper(int argc, char *argv[]) { @@ -55,7 +55,8 @@ const char* xbt_thread_name(xbt_thread_t t) { } const char* xbt_thread_self_name(void) { - return xbt_thread_self()->name; + xbt_thread_t me = xbt_thread_self(); + return me ? me->name : "maestro"; } @@ -77,7 +78,8 @@ void xbt_thread_exit() { } xbt_thread_t xbt_thread_self(void) { - return SIMIX_process_get_data(SIMIX_process_self()); + smx_process_t p = SIMIX_process_self(); + return p ? SIMIX_process_get_data(p) : NULL; } void xbt_thread_yield(void) {