Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d892dde8eeb28cbebc6bd3c72faef4d8ebb6b233
[simgrid.git] / src / mc / mc_comm_determinism.c
1 /* Copyright (c) 2008-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "mc_state.h"
8 #include "mc_comm_pattern.h"
9 #include "mc_request.h"
10 #include "mc_safety.h"
11 #include "mc_private.h"
12 #include "mc_record.h"
13
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc,
15                                 "Logging specific to MC communication determinism detection");
16
17 /********** Global variables **********/
18
19 xbt_dynar_t initial_communications_pattern;
20 xbt_dynar_t incomplete_communications_pattern;
21
22 /********** Static functions ***********/
23
24 static void comm_pattern_free(mc_comm_pattern_t p)
25 {
26   xbt_free(p->rdv);
27   xbt_free(p->data);
28   xbt_free(p);
29   p = NULL;
30 }
31
32 static void list_comm_pattern_free(mc_list_comm_pattern_t l)
33 {
34   xbt_dynar_free(&(l->list));
35   xbt_free(l);
36   l = NULL;
37 }
38
39 static e_mc_comm_pattern_difference_t compare_comm_pattern(mc_comm_pattern_t comm1, mc_comm_pattern_t comm2) {
40   if(comm1->type != comm2->type)
41     return TYPE_DIFF;
42   if (strcmp(comm1->rdv, comm2->rdv) != 0)
43     return RDV_DIFF;
44   if (comm1->src_proc != comm2->src_proc)
45     return SRC_PROC_DIFF;
46   if (comm1->dst_proc != comm2->dst_proc)
47     return DST_PROC_DIFF;
48   if (comm1->data_size != comm2->data_size)
49     return DATA_SIZE_DIFF;
50   if(comm1->data == NULL && comm2->data == NULL)
51     return 0;
52   /*if(comm1->data != NULL && comm2->data !=NULL) {
53     if (!memcmp(comm1->data, comm2->data, comm1->data_size))
54       return 0;
55     return DATA_DIFF;
56   }else{
57     return DATA_DIFF;
58   }*/
59   return 0;
60 }
61
62 static void print_determinism_result(e_mc_comm_pattern_difference_t diff, int process, mc_comm_pattern_t comm, unsigned int cursor) {
63   if (_sg_mc_comms_determinism && !initial_global_state->comm_deterministic) {
64     XBT_INFO("****************************************************");
65     XBT_INFO("***** Non-deterministic communications pattern *****");
66     XBT_INFO("****************************************************");
67     XBT_INFO("The communications pattern of the process %d is different!",  process);
68     switch(diff) {
69     case TYPE_DIFF:
70       XBT_INFO("Different communication type for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
71       break;
72     case RDV_DIFF:
73       XBT_INFO("Different communication rdv for communication %s at index %d",  comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
74       break;
75     case SRC_PROC_DIFF:
76         XBT_INFO("Different communication source process for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
77       break;
78     case DST_PROC_DIFF:
79         XBT_INFO("Different communication destination process for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
80       break;
81     case DATA_SIZE_DIFF:
82       XBT_INFO("Different communication data size for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
83       break;
84     case DATA_DIFF:
85       XBT_INFO("Different communication data for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
86       break;
87     default:
88       break;
89     }
90     MC_print_statistics(mc_stats);
91     xbt_abort();
92   } else if (_sg_mc_send_determinism && !initial_global_state->send_deterministic) {
93     XBT_INFO("*********************************************************");
94     XBT_INFO("***** Non-send-deterministic communications pattern *****");
95     XBT_INFO("*********************************************************");
96     XBT_INFO("The communications pattern of the process %d is different!",  process);
97     switch(diff) {
98     case TYPE_DIFF:
99       XBT_INFO("Different communication type for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
100       break;
101     case RDV_DIFF:
102       XBT_INFO("Different communication rdv for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
103       break;
104     case SRC_PROC_DIFF:
105         XBT_INFO("Different communication source process for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
106       break;
107     case DST_PROC_DIFF:
108         XBT_INFO("Different communication destination process for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
109       break;
110     case DATA_SIZE_DIFF:
111       XBT_INFO("Different communication data size for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
112       break;
113     case DATA_DIFF:
114       XBT_INFO("Different communication data for communication %s at index %d", comm->type == SIMIX_COMM_SEND ? "Send" : "Recv", cursor);
115       break;
116     default:
117       break;
118     }
119     MC_print_statistics(mc_stats);
120     xbt_abort();
121   }
122 }
123
124 static void print_communications_pattern()
125 {
126   unsigned int cursor = 0, cursor2 = 0;
127   mc_comm_pattern_t current_comm;
128   mc_list_comm_pattern_t current_list;
129   unsigned int current_process = 1;
130   while (current_process < simix_process_maxpid) {
131     current_list = (mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, current_process, mc_list_comm_pattern_t);
132     XBT_INFO("Communications from the process %u:", current_process);
133     while(cursor2 < current_list->index_comm){
134       current_comm = (mc_comm_pattern_t)xbt_dynar_get_as(current_list->list, cursor2, mc_comm_pattern_t);
135       if (current_comm->type == SIMIX_COMM_SEND) {
136         XBT_INFO("(%u) [(%lu) %s -> (%lu) %s] %s ", cursor,current_comm->src_proc,
137                  current_comm->src_host, current_comm->dst_proc,
138                  current_comm->dst_host, "iSend");
139       } else {
140         XBT_INFO("(%u) [(%lu) %s <- (%lu) %s] %s ", cursor, current_comm->dst_proc,
141                  current_comm->dst_host, current_comm->src_proc,
142                  current_comm->src_host, "iRecv");
143       }
144       cursor2++;
145     }
146     current_process++;
147     cursor = 0;
148     cursor2 = 0;
149   }
150 }
151
152 static void print_incomplete_communications_pattern(){
153   unsigned int cursor = 0;
154   unsigned int current_process = 1;
155   xbt_dynar_t current_pattern;
156   mc_comm_pattern_t comm;
157   while (current_process < simix_process_maxpid) {
158     current_pattern = (xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, current_process, xbt_dynar_t);
159     XBT_INFO("Incomplete communications from the process %u:", current_process);
160     xbt_dynar_foreach(current_pattern, cursor, comm) {
161       XBT_DEBUG("(%u) Communication %p", cursor, comm);
162     }
163     current_process++;
164     cursor = 0;
165   }
166 }
167
168 // FIXME, remote comm
169 static void update_comm_pattern(mc_comm_pattern_t comm_pattern, smx_synchro_t comm)
170 {
171   mc_process_t process = &mc_model_checker->process;
172   void *addr_pointed;
173   comm_pattern->src_proc = comm->comm.src_proc->pid;
174   comm_pattern->dst_proc = comm->comm.dst_proc->pid;
175   // FIXME, get remote host name
176   comm_pattern->src_host = simcall_host_get_name(comm->comm.src_proc->smx_host);
177   comm_pattern->dst_host = simcall_host_get_name(comm->comm.dst_proc->smx_host);
178   if (comm_pattern->data_size == -1 && comm->comm.src_buff != NULL) {
179     comm_pattern->data_size = *(comm->comm.dst_buff_size);
180     comm_pattern->data = xbt_malloc0(comm_pattern->data_size);
181     addr_pointed = *(void **) comm->comm.src_buff;
182     if (addr_pointed > (void*) process->heap_address
183         && addr_pointed < MC_process_get_heap(process)->breakval)
184       memcpy(comm_pattern->data, addr_pointed, comm_pattern->data_size);
185     else
186       memcpy(comm_pattern->data, comm->comm.src_buff, comm_pattern->data_size);
187   }
188 }
189
190 static void deterministic_comm_pattern(int process, mc_comm_pattern_t comm, int backtracking) {
191
192   mc_list_comm_pattern_t list_comm_pattern = (mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, process, mc_list_comm_pattern_t);
193
194   if(!backtracking){
195     mc_comm_pattern_t initial_comm = xbt_dynar_get_as(list_comm_pattern->list, comm->index, mc_comm_pattern_t);
196     e_mc_comm_pattern_difference_t diff;
197     
198     if((diff = compare_comm_pattern(initial_comm, comm)) != NONE_DIFF){
199       if (comm->type == SIMIX_COMM_SEND)
200         initial_global_state->send_deterministic = 0;
201       initial_global_state->comm_deterministic = 0;
202       print_determinism_result(diff, process, comm, list_comm_pattern->index_comm + 1);
203     }
204   }
205     
206   list_comm_pattern->index_comm++;
207   comm_pattern_free(comm);
208
209 }
210
211 /********** Non Static functions ***********/
212
213 void comm_pattern_free_voidp(void *p) {
214   comm_pattern_free((mc_comm_pattern_t) * (void **) p);
215 }
216
217 void list_comm_pattern_free_voidp(void *p) {
218   list_comm_pattern_free((mc_list_comm_pattern_t) * (void **) p);
219 }
220
221 void get_comm_pattern(const xbt_dynar_t list, const smx_simcall_t request, const e_mc_call_type_t call_type)
222 {
223   mc_process_t process = &mc_model_checker->process;
224   mc_comm_pattern_t pattern = NULL;
225   pattern = xbt_new0(s_mc_comm_pattern_t, 1);
226   pattern->data_size = -1;
227   pattern->data = NULL;
228
229   const smx_process_t issuer = MC_process_get_issuer(&mc_model_checker->process, request);
230   mc_list_comm_pattern_t initial_pattern =
231     (mc_list_comm_pattern_t) xbt_dynar_get_as(initial_communications_pattern, issuer->pid, mc_list_comm_pattern_t);
232   xbt_dynar_t incomplete_pattern =
233     (xbt_dynar_t) xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
234   pattern->index =
235     initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
236   
237   void *addr_pointed;
238   
239   if (call_type == MC_CALL_TYPE_SEND) {
240     /* Create comm pattern */
241     pattern->type = SIMIX_COMM_SEND;
242     pattern->comm = simcall_comm_isend__get__result(request);
243     pattern->rdv = (pattern->comm->comm.rdv != NULL) ? strdup(pattern->comm->comm.rdv->name) : strdup(pattern->comm->comm.rdv_cpy->name);
244     pattern->src_proc = pattern->comm->comm.src_proc->pid;
245     // FIXME, get remote host name
246     pattern->src_host = simcall_host_get_name(issuer->smx_host);
247     if(pattern->comm->comm.src_buff != NULL){
248       pattern->data_size = pattern->comm->comm.src_buff_size;
249       pattern->data = xbt_malloc0(pattern->data_size);
250       addr_pointed = *(void **) pattern->comm->comm.src_buff;
251       if (addr_pointed > (void*) process->heap_address
252           && addr_pointed < MC_process_get_heap(process)->breakval)
253         memcpy(pattern->data, addr_pointed, pattern->data_size);
254       else
255         memcpy(pattern->data, pattern->comm->comm.src_buff, pattern->data_size);
256     }
257   } else if (call_type == MC_CALL_TYPE_RECV) {                      
258     pattern->type = SIMIX_COMM_RECEIVE;
259     pattern->comm = simcall_comm_irecv__get__result(request);
260     pattern->rdv = (pattern->comm->comm.rdv != NULL) ? strdup(pattern->comm->comm.rdv->name) : strdup(pattern->comm->comm.rdv_cpy->name);
261     pattern->dst_proc = pattern->comm->comm.dst_proc->pid;
262     // FIXME, remote process access
263     pattern->dst_host = simcall_host_get_name(issuer->smx_host);
264   } else {
265     xbt_die("Unexpected call_type %i", (int) call_type);
266   }
267
268   xbt_dynar_push((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t), &pattern);
269
270   XBT_DEBUG("Insert incomplete comm pattern %p for process %lu", pattern, issuer->pid);
271 }
272
273 void complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm, int backtracking) {
274
275   mc_comm_pattern_t current_comm_pattern;
276   unsigned int cursor = 0;
277   unsigned int src = comm->comm.src_proc->pid;
278   unsigned int dst = comm->comm.dst_proc->pid;
279   mc_comm_pattern_t src_comm_pattern;
280   mc_comm_pattern_t dst_comm_pattern;
281   int src_completed = 0, dst_completed = 0;
282
283   /* Complete comm pattern */
284   xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, current_comm_pattern) {
285     if (current_comm_pattern-> comm == comm) {
286       update_comm_pattern(current_comm_pattern, comm);
287       src_completed = 1;
288       xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, &src_comm_pattern);
289       XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", src, cursor);
290       break;
291     }
292   }
293   if(!src_completed)
294     xbt_die("Corresponding communication for the source process not found!");
295
296   cursor = 0;
297
298   xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, current_comm_pattern) {
299     if (current_comm_pattern-> comm == comm) {
300       update_comm_pattern(current_comm_pattern, comm);
301       dst_completed = 1;
302       xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, &dst_comm_pattern);
303       XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", dst, cursor);
304       break;
305     }
306   }
307   if(!dst_completed)
308     xbt_die("Corresponding communication for the destination process not found!");
309   
310   if (!initial_global_state->initial_communications_pattern_done) {
311     /* Store comm pattern */
312     if(src_comm_pattern->index < xbt_dynar_length(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list)){
313       xbt_dynar_set(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list, src_comm_pattern->index, &src_comm_pattern);
314       ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list->used++;
315     } else {
316       xbt_dynar_insert_at(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list, src_comm_pattern->index, &src_comm_pattern);
317     }
318     
319     if(dst_comm_pattern->index < xbt_dynar_length(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list)) {
320       xbt_dynar_set(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list, dst_comm_pattern->index, &dst_comm_pattern);
321       ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list->used++;
322     } else {
323       xbt_dynar_insert_at(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list, dst_comm_pattern->index, &dst_comm_pattern);
324     }
325     ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->index_comm++;
326     ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->index_comm++;
327   } else {
328     /* Evaluate comm determinism */
329     deterministic_comm_pattern(src, src_comm_pattern, backtracking);
330     deterministic_comm_pattern(dst, dst_comm_pattern, backtracking);
331   }
332 }
333
334 /************************ Main algorithm ************************/
335
336 void MC_pre_modelcheck_comm_determinism(void)
337 {
338   MC_SET_MC_HEAP;
339
340   mc_state_t initial_state = NULL;
341   smx_process_t process;
342   int i;
343
344   if (_sg_mc_visited > 0)
345     visited_states = xbt_dynar_new(sizeof(mc_visited_state_t), visited_state_free_voidp);
346  
347   initial_communications_pattern = xbt_dynar_new(sizeof(mc_list_comm_pattern_t), list_comm_pattern_free_voidp);
348   for (i=0; i<simix_process_maxpid; i++){
349     mc_list_comm_pattern_t process_list_pattern = xbt_new0(s_mc_list_comm_pattern_t, 1);
350     process_list_pattern->list = xbt_dynar_new(sizeof(mc_comm_pattern_t), comm_pattern_free_voidp);
351     process_list_pattern->index_comm = 0;
352     xbt_dynar_insert_at(initial_communications_pattern, i, &process_list_pattern);
353   }
354   incomplete_communications_pattern = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
355   for (i=0; i<simix_process_maxpid; i++){
356     xbt_dynar_t process_pattern = xbt_dynar_new(sizeof(mc_comm_pattern_t), NULL);
357     xbt_dynar_insert_at(incomplete_communications_pattern, i, &process_pattern);
358   }
359
360   initial_state = MC_state_new();
361   MC_SET_STD_HEAP;
362   
363   XBT_DEBUG("********* Start communication determinism verification *********");
364
365   /* Wait for requests (schedules processes) */
366   MC_wait_for_requests();
367
368   MC_SET_MC_HEAP;
369
370   /* Get an enabled process and insert it in the interleave set of the initial state */
371   MC_EACH_SIMIX_PROCESS(process,
372     if (MC_process_is_enabled(process)) {
373       MC_state_interleave_process(initial_state, process);
374     }
375   );
376
377   xbt_fifo_unshift(mc_stack, initial_state);
378
379   MC_SET_STD_HEAP;
380
381 }
382
383 void MC_modelcheck_comm_determinism(void)
384 {
385
386   char *req_str = NULL;
387   int value;
388   mc_visited_state_t visited_state = NULL;
389   smx_simcall_t req = NULL;
390   smx_process_t process = NULL;
391   mc_state_t state = NULL, next_state = NULL;
392
393   while (xbt_fifo_size(mc_stack) > 0) {
394
395     /* Get current state */
396     state = (mc_state_t) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
397
398     XBT_DEBUG("**************************************************");
399     XBT_DEBUG("Exploration depth = %d (state = %d, interleaved processes = %d)",
400               xbt_fifo_size(mc_stack), state->num,
401               MC_state_interleave_size(state));
402
403     /* Update statistics */
404     mc_stats->visited_states++;
405
406     if ((xbt_fifo_size(mc_stack) <= _sg_mc_max_depth)
407         && (req = MC_state_get_request(state, &value))
408         && (visited_state == NULL)) {
409
410       req_str = MC_request_to_string(req, value);  
411       XBT_DEBUG("Execute: %s", req_str);                 
412       xbt_free(req_str);
413       
414       if (dot_output != NULL) {
415         MC_SET_MC_HEAP;
416         req_str = MC_request_get_dot_output(req, value);
417         MC_SET_STD_HEAP;
418       }
419
420       MC_state_set_executed_request(state, req, value);
421       mc_stats->executed_transitions++;
422
423       /* TODO : handle test and testany simcalls */
424       e_mc_call_type_t call = MC_CALL_TYPE_NONE;
425       if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
426         call = mc_get_call_type(req);
427       }
428
429       /* Answer the request */
430       MC_simcall_handle(req, value);    /* After this call req is no longer useful */
431
432       MC_SET_MC_HEAP;
433       if(!initial_global_state->initial_communications_pattern_done)
434         handle_comm_pattern(call, req, value, initial_communications_pattern, 0);
435       else
436         handle_comm_pattern(call, req, value, NULL, 0);
437       MC_SET_STD_HEAP;
438
439       /* Wait for requests (schedules processes) */
440       MC_wait_for_requests();
441
442       /* Create the new expanded state */
443       MC_SET_MC_HEAP;
444
445       next_state = MC_state_new();
446
447       if ((visited_state = is_visited_state(next_state)) == NULL) {
448
449         /* Get enabled processes and insert them in the interleave set of the next state */
450         MC_EACH_SIMIX_PROCESS(process,
451           if (MC_process_is_enabled(process)) {
452             MC_state_interleave_process(next_state, process);
453           }
454         );
455
456         if (dot_output != NULL)
457           fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num,  next_state->num, req_str);
458
459       } else {
460
461         if (dot_output != NULL)
462           fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str);
463
464       }
465
466       xbt_fifo_unshift(mc_stack, next_state);
467
468       if (dot_output != NULL)
469         xbt_free(req_str);
470
471       MC_SET_STD_HEAP;
472
473     } else {
474
475       if (xbt_fifo_size(mc_stack) > _sg_mc_max_depth) {
476         XBT_WARN("/!\\ Max depth reached ! /!\\ ");
477       } else if (visited_state != NULL) {
478         XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.", visited_state->other_num == -1 ? visited_state->num : visited_state->other_num);
479       } else {
480         XBT_DEBUG("There are no more processes to interleave. (depth %d)", xbt_fifo_size(mc_stack));
481       }
482
483       MC_SET_MC_HEAP;
484
485       if (!initial_global_state->initial_communications_pattern_done) 
486         initial_global_state->initial_communications_pattern_done = 1;
487
488       /* Trash the current state, no longer needed */
489       xbt_fifo_shift(mc_stack);
490       MC_state_delete(state, !state->in_visited_states ? 1 : 0);
491       XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
492
493       MC_SET_STD_HEAP;
494
495       visited_state = NULL;
496
497       /* Check for deadlocks */
498       if (MC_deadlock_check()) {
499         MC_show_deadlock(NULL);
500         return;
501       }
502
503       MC_SET_MC_HEAP;
504
505       while ((state = xbt_fifo_shift(mc_stack)) != NULL) {
506         if (MC_state_interleave_size(state) && xbt_fifo_size(mc_stack) < _sg_mc_max_depth) {
507           /* We found a back-tracking point, let's loop */
508           XBT_DEBUG("Back-tracking to state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
509           xbt_fifo_unshift(mc_stack, state);
510           MC_SET_STD_HEAP;
511
512           MC_replay(mc_stack);
513
514           XBT_DEBUG("Back-tracking to state %d at depth %d done", state->num, xbt_fifo_size(mc_stack));
515
516           break;
517         } else {
518           XBT_DEBUG("Delete state %d at depth %d", state->num, xbt_fifo_size(mc_stack) + 1);
519           MC_state_delete(state, !state->in_visited_states ? 1 : 0);
520         }
521       }
522
523       MC_SET_STD_HEAP;
524     }
525   }
526
527   MC_print_statistics(mc_stats);
528   MC_SET_STD_HEAP;
529
530   return;
531 }