XBT_PUBLIC(void) xbt_init(int *argc, char **argv);
XBT_PUBLIC(void) xbt_exit(void);
+XBT_PUBLIC_DATA(int) smx_cleaned;
+XBT_PUBLIC_DATA(int) xbt_initialized;
SG_END_DECL()
exit(0);
}
+int smx_cleaned = 0;
/**
* \ingroup SIMIX_API
* \brief Clean the SIMIX simulation
*/
void SIMIX_clean(void)
{
- static int cleaned = 0;
#ifdef TIME_BENCH_PER_SR
smx_ctx_raw_new_sr();
#endif
- if (cleaned) return; // to avoid double cleaning by java and C
- cleaned = 1;
+ if (smx_cleaned) return; // to avoid double cleaning by java and C
+ smx_cleaned = 1;
XBT_DEBUG("SIMIX_clean called. Simulation's over.");
if (!xbt_dynar_is_empty(simix_global->process_to_run) && SIMIX_get_clock() == 0.0) {
XBT_CRITICAL(" ");
XBT_CRITICAL("%s", e->msg);
xbt_free(thrower);
+ if (xbt_initialized==0 || smx_cleaned) {
+ fprintf(stderr, "Ouch. SimGrid is not initialized yet, or already closing. No backtrace available.\n");
+ return; /* Not started yet or already closing. Trying to generate a backtrace would probably fail */
+ }
+
if (!e->bt_strings)
xbt_ex_setup_backtrace(e);
static void xbt_postexit(void)
{
if(!_sg_do_clean_atexit) return;
+ xbt_initialized--;
xbt_backtrace_postexit();
xbt_fifo_postexit();
xbt_dict_postexit();