Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : fclose forgotten in get_memory_map_addr
[simgrid.git] / src / mc / mc_liveness.c
1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved.            */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "mc_private.h"
7 #include <unistd.h>
8
9 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
10                                 "Logging specific to algorithms for liveness properties verification");
11
12 xbt_dynar_t reached_pairs;
13 xbt_dynar_t reached_pairs_hash;
14 xbt_dynar_t visited_pairs;
15 xbt_dynar_t visited_pairs_hash;
16 xbt_dynar_t successors;
17
18 xbt_dynar_t hosts_table;
19
20
21 /* fast implementation of djb2 algorithm */
22 unsigned int hash_region(char *str, int str_len){
23
24   int c;
25   register unsigned int hash = 5381;
26
27   while (str_len--) {
28     c = *str++;
29     hash = ((hash << 5) + hash) + c;    /* hash * 33 + c */
30   }
31
32   return hash;
33
34 }
35
36 const char* get_memory_map_addr(void *addr){
37
38   FILE *fp;                     /* File pointer to process's proc maps file */
39   char *line = NULL;            /* Temporal storage for each line that is readed */
40   ssize_t read;                 /* Number of bytes readed */
41   size_t n = 0;                 /* Amount of bytes to read by getline */
42
43   fp = fopen("/proc/self/maps", "r");
44   
45   if(fp == NULL)
46     perror("fopen failed");
47
48   if(addr == NULL){
49     fclose(fp);
50     return "nil";
51   }
52
53   xbt_dynar_t lfields = NULL;
54   xbt_dynar_t start_end  = NULL;
55   void *start_addr;
56   void *end_addr;
57
58   while ((read = getline(&line, &n, fp)) != -1) {
59
60     xbt_str_trim(line, NULL);
61     xbt_str_strip_spaces(line);
62     lfields = xbt_str_split(line,NULL);
63
64     start_end = xbt_str_split(xbt_dynar_get_as(lfields, 0, char*), "-");
65     start_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 0, char*), NULL, 16);
66     end_addr = (void *) strtoul(xbt_dynar_get_as(start_end, 1, char*), NULL, 16);
67
68     if((addr > start_addr) && ( addr < end_addr)){
69       free(line);
70       fclose(fp);
71       if(start_addr == std_heap)
72         return "std_heap";
73       if(start_addr == raw_heap)
74         return "raw_heap";
75       if(xbt_dynar_length(lfields) == 6)
76         return xbt_dynar_get_as(lfields, xbt_dynar_length(lfields) - 1, char*);
77       else
78         return "Anonymous";
79     }
80
81   }
82
83   free(line);
84   fclose(fp);
85   return "Unknown area";
86
87 }
88
89 int data_program_region_compare(void *d1, void *d2, size_t size){
90   int distance = 0;
91   int pointer_align;
92   int i;
93   
94   for(i=0; i<size; i++){
95     if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
96       fprintf(stderr,"Different byte (offset=%d) (%p - %p) in data program region\n", i, (char *)d1 + i, (char *)d2 + i);
97       distance++;
98       pointer_align = (i /sizeof(void *)) * sizeof(void *);
99       fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)d1 + pointer_align)),  get_memory_map_addr(*((void **)((char *)d1 + pointer_align))), *((void **)((char *)d2 + pointer_align)), get_memory_map_addr(*((void **)((char *)d2 + pointer_align))));
100     }
101   }
102   
103   fprintf(stderr, "Hamming distance between data program regions : %d\n", distance);
104
105   return distance;
106 }
107
108 int data_libsimgrid_region_compare(void *d1, void *d2, size_t size){
109   int distance = 0;
110   int pointer_align;
111   int i;
112   
113   for(i=0; i<size; i++){
114     if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
115       fprintf(stderr, "Different byte (offset=%d) (%p - %p) in data libsimgrid region\n", i, (char *)d1 + i, (char *)d2 + i);
116       distance++;
117       pointer_align = (i /sizeof(void *)) * sizeof(void *);
118       fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)d1 + pointer_align)), get_memory_map_addr(*((void **)((char *)d1 + pointer_align))), *((void **)((char *)d2 + pointer_align)), get_memory_map_addr(*((void **)((char *)d2 + pointer_align))));
119     }
120   }
121   
122   fprintf(stderr, "Hamming distance between data libsimgrid regions : %d\n", distance);
123   
124   return distance;
125 }
126
127 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, void* s_heap, void* r_heap){
128
129   
130   if(s1->num_reg != s2->num_reg){
131     XBT_DEBUG("Different num_reg (s1 = %u, s2 = %u)", s1->num_reg, s2->num_reg);
132     return 1;
133   }
134
135   int i;
136   int errors = 0;
137
138   for(i=0 ; i< s1->num_reg ; i++){
139
140     if(s1->regions[i]->type != s2->regions[i]->type){
141       if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
142         XBT_DEBUG("Different type of region");
143         errors++;
144       }else{
145         return 1;
146       }
147     }
148
149     switch(s1->regions[i]->type){
150       case 0:
151       if(s1->regions[i]->size != s2->regions[i]->size){
152         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
153           XBT_DEBUG("Different size of heap (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
154           errors++;
155         }else{
156           return 1;
157         }
158       }
159       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
160         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
161           XBT_DEBUG("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
162           errors++;
163         }else{
164           return 1;
165         }
166       }
167       if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data, s_heap, r_heap)){
168         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
169           XBT_DEBUG("Different heap (mmalloc_compare)");
170           errors++; 
171         }else{
172           return 1;
173         }
174       }
175       break;
176     case 1 :
177       if(s1->regions[i]->size != s2->regions[i]->size){
178         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
179           XBT_DEBUG("Different size of libsimgrid (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
180           errors++;
181         }else{
182           return 1;
183         }
184       }
185       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
186         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
187           XBT_DEBUG("Different start addr of libsimgrid (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
188           errors++;
189         }else{
190           return 1;
191         }
192       }
193       if(data_program_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
194         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
195           XBT_DEBUG("Different memcmp for data in libsimgrid");
196           errors++;
197         }else{
198           return 1;
199         }
200       }
201       break;
202     case 2 :
203       if(s1->regions[i]->size != s2->regions[i]->size){
204         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
205           XBT_DEBUG("Different size of data program (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
206           errors++;
207         }else{
208           return 1;
209         }
210       }
211       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
212         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
213           XBT_DEBUG("Different start addr of data program (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
214           errors++;
215         }else{
216           return 1;
217         }
218       }
219       if(data_libsimgrid_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
220         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
221           XBT_DEBUG("Different memcmp for data in libsimgrid");
222           errors++;
223         }else{
224           return 1;
225         }
226       }
227       break;
228     default:
229       break;
230     }
231   }
232
233   return (errors > 0);
234   
235 }
236
237 int reached(xbt_state_t st){
238
239
240   if(xbt_dynar_is_empty(reached_pairs)){
241
242     return 0;
243
244   }else{
245
246     MC_SET_RAW_MEM;
247
248     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
249     MC_take_snapshot_liveness(sn);    
250     
251     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
252     int res;
253     int_f_void_t f;
254
255     /* Get values of propositional symbols */
256     unsigned int cursor = 0;
257     xbt_propositional_symbol_t ps = NULL;
258     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
259       f = (int_f_void_t)ps->function;
260       res = (*f)();
261       xbt_dynar_push_as(prop_ato, int, res);
262     }
263
264     cursor = 0;
265     mc_pair_reached_t pair_test = NULL;
266
267     //xbt_dict_t current_rdv_points = SIMIX_get_rdv_points();
268      
269     xbt_dynar_foreach(reached_pairs, cursor, pair_test){
270       XBT_DEBUG("Pair reached #%u", cursor+1);
271       if(automaton_state_compare(pair_test->automaton_state, st) == 0){
272         if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
273           //XBT_DEBUG("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points));
274           //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){
275           //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){
276           if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){
277                 MC_free_snapshot(sn);
278                 xbt_dynar_reset(prop_ato);
279                 xbt_free(prop_ato);
280                 MC_UNSET_RAW_MEM;
281                 return 1;
282               }
283               /* }
284           }else{
285             XBT_DEBUG("Different size of rdv points (%d - %d)",xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points) );
286             }*/
287         }else{
288           XBT_DEBUG("Different values of propositional symbols");
289         }
290       }else{
291         XBT_DEBUG("Different automaton state");
292       }
293     }
294
295     MC_free_snapshot(sn);
296     xbt_dynar_reset(prop_ato);
297     xbt_free(prop_ato);
298     MC_UNSET_RAW_MEM;
299     return 0;
300     
301   }
302 }
303
304 int rdv_points_compare(xbt_dict_t d1, xbt_dict_t d2){ /* d1 = pair_test, d2 = current_pair */ 
305   
306    xbt_dict_cursor_t cursor_dict = NULL;
307    char *key;
308    char *data;
309    smx_rdv_t rdv1, rdv2;
310    xbt_fifo_item_t item1, item2;
311    smx_action_t action1, action2;
312    xbt_fifo_item_t item_req1, item_req2;
313    smx_simcall_t req1, req2;
314    int i=0;
315    int j=0;
316
317    xbt_dict_foreach(d1, cursor_dict, key, data){
318      rdv1 = (smx_rdv_t)data;
319      rdv2 = xbt_dict_get_or_null(d2, rdv1->name);
320      if(rdv2 == NULL){
321        XBT_DEBUG("Rdv point unknown");
322        return 1;
323      }else{
324        if(xbt_fifo_size(rdv1->comm_fifo) != xbt_fifo_size(rdv2->comm_fifo)){
325          XBT_DEBUG("Different total of actions in mailbox \"%s\" (%d - %d)", rdv1->name, xbt_fifo_size(rdv1->comm_fifo),xbt_fifo_size(rdv2->comm_fifo) );
326          return 1;
327        }else{
328          
329          XBT_DEBUG("Total of actions in mailbox \"%s\" : %d", rdv1->name, xbt_fifo_size(rdv1->comm_fifo)); 
330          
331          item1 = xbt_fifo_get_first_item(rdv1->comm_fifo);      
332          item2 = xbt_fifo_get_first_item(rdv2->comm_fifo);
333
334          while(i<xbt_fifo_size(rdv1->comm_fifo)){
335            action1 = (smx_action_t) xbt_fifo_get_item_content(item1);
336            action2 = (smx_action_t) xbt_fifo_get_item_content(item2);
337
338            if(action1->type != action2->type){
339              XBT_DEBUG("Different type of action");
340              return 1;
341            }
342
343            if(action1->state != action2->state){
344              XBT_DEBUG("Different state of action");
345              return 1;
346            }
347
348            if(xbt_fifo_size(action1->simcalls) != xbt_fifo_size(action2->simcalls)){
349              XBT_DEBUG("Different size of simcall list (%d - %d", xbt_fifo_size(action1->simcalls), xbt_fifo_size(action2->simcalls));
350              return 1;
351            }else{
352
353              item_req1 = xbt_fifo_get_first_item(action1->simcalls);    
354              item_req2 = xbt_fifo_get_first_item(action2->simcalls);
355
356              while(j<xbt_fifo_size(action1->simcalls)){
357
358                req1 = (smx_simcall_t) xbt_fifo_get_item_content(item_req1);
359                req2 = (smx_simcall_t) xbt_fifo_get_item_content(item_req2);
360                
361                if(req1->call != req2->call){
362                  XBT_DEBUG("Different simcall call in simcalls of action (%d - %d)", (int)req1->call, (int)req2->call);
363                  return 1;
364                }
365                if(req1->issuer->pid != req2->issuer->pid){
366                  XBT_DEBUG("Different simcall issuer in simcalls of action (%lu- %lu)", req1->issuer->pid, req2->issuer->pid);
367                  return 1;
368                }
369
370                item_req1 = xbt_fifo_get_next_item(item_req1);   
371                item_req2 = xbt_fifo_get_next_item(item_req2);
372                j++;
373                
374              }
375            }
376
377            switch(action1->type){
378            case 0: /* execution */
379            case 1: /* parallel execution */
380              if(strcmp(action1->execution.host->name, action2->execution.host->name) != 0)
381                return 1;
382              break;
383            case 2: /* comm */
384              if(action1->comm.type != action2->comm.type)
385                return 1;
386              //XBT_DEBUG("Type of comm : %d", action1->comm.type);
387              
388              switch(action1->comm.type){
389              case 0: /* SEND */
390                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
391                  return 1;
392                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
393                  return 1;
394                break;
395              case 1: /* RECEIVE */
396                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
397                  return 1;
398                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
399                  return 1;
400                break;
401              case 2: /* READY */
402                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
403                  return 1;
404                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
405                  return 1;
406                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
407                  return 1;
408                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
409                  return 1;
410                break;
411              case 3: /* DONE */
412                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
413                  return 1;
414                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
415                  return 1;
416                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
417                  return 1;
418                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
419                  return 1;
420                break;
421                
422              } /* end of switch on type of comm */
423              
424              if(action1->comm.refcount != action2->comm.refcount)
425                return 1;
426              if(action1->comm.detached != action2->comm.detached)
427                return 1;
428              if(action1->comm.rate != action2->comm.rate)
429                return 1;
430              if(action1->comm.task_size != action2->comm.task_size)
431                return 1;
432              if(action1->comm.src_buff != action2->comm.src_buff)
433                return 1;
434              if(action1->comm.dst_buff != action2->comm.dst_buff)
435                return 1;
436              if(action1->comm.src_data != action2->comm.src_data)
437                return 1;
438              if(action1->comm.dst_data != action2->comm.dst_data)
439                return 1;
440              
441              break;
442            case 3: /* sleep */
443              if(strcmp(action1->sleep.host->name, action2->sleep.host->name) != 0)
444                return 1;
445              break;
446            case 4: /* synchro */
447              
448              break;
449            default:
450              break;
451            }
452
453            item1 = xbt_fifo_get_next_item(item1);       
454            item2 = xbt_fifo_get_next_item(item2);
455            i++;
456          }
457        }
458      }
459    }
460
461    return 0;
462    
463 }
464
465 void set_pair_reached(xbt_state_t st){
466
467  
468   MC_SET_RAW_MEM;
469   
470   mc_pair_reached_t pair = NULL;
471   pair = xbt_new0(s_mc_pair_reached_t, 1);
472   pair->automaton_state = st;
473   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
474   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
475   //pair->rdv_points = xbt_dict_new();  
476   MC_take_snapshot_liveness(pair->system_state);
477
478   /* Get values of propositional symbols */
479   unsigned int cursor = 0;
480   xbt_propositional_symbol_t ps = NULL;
481   int res;
482   int_f_void_t f;
483
484   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
485     f = (int_f_void_t)ps->function;
486     res = (*f)();
487     xbt_dynar_push_as(pair->prop_ato, int, res);
488   }
489
490   /*xbt_dict_t rdv_points = SIMIX_get_rdv_points();
491
492   xbt_dict_cursor_t cursor_dict = NULL;
493   char *key;
494   char *data;
495   xbt_fifo_item_t item;
496   smx_action_t action;
497
498   xbt_dict_foreach(rdv_points, cursor_dict, key, data){
499     smx_rdv_t new_rdv = xbt_new0(s_smx_rvpoint_t, 1);
500     new_rdv->name = strdup(((smx_rdv_t)data)->name);
501     new_rdv->comm_fifo = xbt_fifo_new();
502     xbt_fifo_foreach(((smx_rdv_t)data)->comm_fifo, item, action, smx_action_t) {
503       smx_action_t a = xbt_new0(s_smx_action_t, 1);
504       memcpy(a, action, sizeof(s_smx_action_t));
505       xbt_fifo_push(new_rdv->comm_fifo, a);
506       XBT_DEBUG("New action (type = %d, state = %d) in mailbox \"%s\"", action->type, action->state, key);
507       if(action->type==2)
508         XBT_DEBUG("Type of communication : %d, Ref count = %d", action->comm.type, action->comm.refcount);
509     }
510     //new_rdv->comm_fifo = xbt_fifo_copy(((smx_rdv_t)data)->comm_fifo);
511     xbt_dict_set(pair->rdv_points, new_rdv->name, new_rdv, NULL);
512     }*/
513  
514   xbt_dynar_push(reached_pairs, &pair); 
515
516   MC_UNSET_RAW_MEM;
517   
518 }
519
520
521 int reached_hash(xbt_state_t st){
522
523
524   if(xbt_dynar_is_empty(reached_pairs_hash)){
525
526     return 0;
527
528   }else{
529
530     MC_SET_RAW_MEM;
531
532     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
533     MC_take_snapshot_liveness(sn);
534
535     int j;
536     unsigned int hash_regions[sn->num_reg];
537     for(j=0; j<sn->num_reg; j++){
538       hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
539     }
540
541
542     /* Get values of propositional symbols */
543     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
544     unsigned int cursor = 0;
545     xbt_propositional_symbol_t ps = NULL;
546     int res;
547     int_f_void_t f;
548
549     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
550       f = (int_f_void_t)ps->function;
551       res = (*f)();
552       xbt_dynar_push_as(prop_ato, int, res);
553     }
554
555     mc_pair_reached_hash_t pair_test = NULL;
556
557     int region_diff = 0;
558
559     cursor = 0;
560
561     xbt_dynar_foreach(reached_pairs_hash, cursor, pair_test){
562
563       if(automaton_state_compare(pair_test->automaton_state, st) == 0){
564         if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
565           for(j=0 ; j< sn->num_reg ; j++){
566             if(hash_regions[j] != pair_test->hash_regions[j]){
567               region_diff++;
568             }
569           }
570           if(region_diff == 0){
571             MC_free_snapshot(sn);
572             xbt_dynar_reset(prop_ato);
573             xbt_free(prop_ato);
574             MC_UNSET_RAW_MEM;
575             return 1;
576           }else{
577             XBT_DEBUG("Different snapshot");
578           }
579         }else{
580           XBT_DEBUG("Different values of propositional symbols");
581         }
582       }else{
583         XBT_DEBUG("Different automaton state");
584       }
585
586       region_diff = 0;
587     }
588     
589     MC_free_snapshot(sn);
590     xbt_dynar_reset(prop_ato);
591     xbt_free(prop_ato);
592     MC_UNSET_RAW_MEM;
593     return 0;
594     
595   }
596 }
597
598 void set_pair_reached_hash(xbt_state_t st){
599  
600   MC_SET_RAW_MEM;
601
602   mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
603   MC_take_snapshot_liveness(sn);
604  
605   mc_pair_reached_hash_t pair = NULL;
606   pair = xbt_new0(s_mc_pair_reached_hash_t, 1);
607   pair->automaton_state = st;
608   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
609   pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
610   
611   int i;
612
613   for(i=0 ; i< sn->num_reg ; i++){
614     pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
615   }
616   
617   /* Get values of propositional symbols */
618   unsigned int cursor = 0;
619   xbt_propositional_symbol_t ps = NULL;
620   int res;
621   int_f_void_t f;
622
623   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
624     f = (int_f_void_t)ps->function;
625     res = (*f)();
626     xbt_dynar_push_as(pair->prop_ato, int, res);
627   }
628   
629   xbt_dynar_push(reached_pairs_hash, &pair);
630
631   MC_free_snapshot(sn);
632   
633   MC_UNSET_RAW_MEM;
634     
635 }
636
637
638 int visited(xbt_state_t st, int sc){
639
640
641   if(xbt_dynar_is_empty(visited_pairs)){
642
643     return 0;
644
645   }else{
646
647     MC_SET_RAW_MEM;
648
649     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
650     MC_take_snapshot_liveness(sn);
651
652     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
653
654     /* Get values of propositional symbols */
655     unsigned int cursor = 0;
656     xbt_propositional_symbol_t ps = NULL;
657     int res;
658     int_f_void_t f;
659
660     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
661       f = (int_f_void_t)ps->function;
662       res = (*f)();
663       xbt_dynar_push_as(prop_ato, int, res);
664     }
665
666     cursor = 0;
667     mc_pair_visited_t pair_test = NULL;
668
669     xbt_dynar_foreach(visited_pairs, cursor, pair_test){
670       if(pair_test->search_cycle == sc) {
671         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
672           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
673             if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){
674             
675               MC_free_snapshot(sn);
676               xbt_dynar_reset(prop_ato);
677               xbt_free(prop_ato);
678               MC_UNSET_RAW_MEM;
679                 
680               return 1;
681         
682             }else{
683               XBT_DEBUG("Different snapshot");
684             }
685           }else{
686             XBT_DEBUG("Different values of propositional symbols"); 
687           }
688         }else{
689           XBT_DEBUG("Different automaton state");
690         }
691       }else{
692         XBT_DEBUG("Different value of search_cycle");
693       }
694     }
695
696
697     MC_free_snapshot(sn);
698     xbt_dynar_reset(prop_ato);
699     xbt_free(prop_ato);
700     MC_UNSET_RAW_MEM;
701     return 0;
702     
703   }
704 }
705
706
707 int visited_hash(xbt_state_t st, int sc){
708
709
710   if(xbt_dynar_is_empty(visited_pairs_hash)){
711
712     return 0;
713
714   }else{
715
716     MC_SET_RAW_MEM;
717
718     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
719     MC_take_snapshot_liveness(sn);
720
721     int j;
722     unsigned int hash_regions[sn->num_reg];
723     for(j=0; j<sn->num_reg; j++){
724       hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
725     }
726
727     
728     /* Get values of propositional symbols */
729     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
730     unsigned int cursor = 0;
731     xbt_propositional_symbol_t ps = NULL;
732     int res;
733     int_f_void_t f;
734
735     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
736       f = (int_f_void_t)ps->function;
737       res = (*f)();
738       xbt_dynar_push_as(prop_ato, int, res);
739     }
740
741     mc_pair_visited_hash_t pair_test = NULL;
742
743     int region_diff = 0;
744     cursor = 0;
745
746     xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
747   
748       if(pair_test->search_cycle == sc) {
749         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
750           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
751             for(j=0 ; j< sn->num_reg ; j++){
752               if(hash_regions[j] != pair_test->hash_regions[j]){
753                 region_diff++;
754               }
755             }
756             if(region_diff == 0){
757               MC_free_snapshot(sn);
758               xbt_dynar_reset(prop_ato);
759               xbt_free(prop_ato);
760               MC_UNSET_RAW_MEM;
761               return 1;
762             }else{
763               //XBT_DEBUG("Different snapshot");
764             }
765           }else{
766             //XBT_DEBUG("Different values of propositional symbols"); 
767           }
768         }else{
769           //XBT_DEBUG("Different automaton state");
770         }
771       }else{
772         //XBT_DEBUG("Different value of search_cycle");
773       }
774       
775       region_diff = 0;
776     }
777     
778     MC_free_snapshot(sn);
779     xbt_dynar_reset(prop_ato);
780     xbt_free(prop_ato);
781     MC_UNSET_RAW_MEM;
782     return 0;
783     
784   }
785 }
786
787 void set_pair_visited_hash(xbt_state_t st, int sc){
788  
789   MC_SET_RAW_MEM;
790
791   mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
792   MC_take_snapshot_liveness(sn);
793  
794   mc_pair_visited_hash_t pair = NULL;
795   pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
796   pair->automaton_state = st;
797   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
798   pair->search_cycle = sc;
799   pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
800   
801   int i;
802
803   for(i=0 ; i< sn->num_reg ; i++){
804     pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
805   }
806   
807   /* Get values of propositional symbols */
808   unsigned int cursor = 0;
809   xbt_propositional_symbol_t ps = NULL;
810   int res;
811   int_f_void_t f;
812
813   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
814     f = (int_f_void_t)ps->function;
815     res = (*f)();
816     xbt_dynar_push_as(pair->prop_ato, int, res);
817   }
818   
819   xbt_dynar_push(visited_pairs_hash, &pair);
820
821   MC_free_snapshot(sn);
822   
823   MC_UNSET_RAW_MEM;
824     
825 }
826
827 void set_pair_visited(xbt_state_t st, int sc){
828
829  
830   MC_SET_RAW_MEM;
831  
832   mc_pair_visited_t pair = NULL;
833   pair = xbt_new0(s_mc_pair_visited_t, 1);
834   pair->automaton_state = st;
835   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
836   pair->search_cycle = sc;
837   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
838   MC_take_snapshot_liveness(pair->system_state);
839
840
841   /* Get values of propositional symbols */
842   unsigned int cursor = 0;
843   xbt_propositional_symbol_t ps = NULL;
844   int res;
845   int_f_void_t f;
846
847   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
848     f = (int_f_void_t)ps->function;
849     res = (*f)();
850     xbt_dynar_push_as(pair->prop_ato, int, res);
851   }
852   
853   xbt_dynar_push(visited_pairs, &pair);
854   
855   MC_UNSET_RAW_MEM;
856   
857   
858 }
859
860 void MC_pair_delete(mc_pair_t pair){
861   xbt_free(pair->graph_state->proc_status);
862   xbt_free(pair->graph_state);
863   xbt_free(pair);
864 }
865
866
867
868 int MC_automaton_evaluate_label(xbt_exp_label_t l){
869   
870   switch(l->type){
871   case 0 : {
872     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
873     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
874     return (left_res || right_res);
875   }
876   case 1 : {
877     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
878     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
879     return (left_res && right_res);
880   }
881   case 2 : {
882     int res = MC_automaton_evaluate_label(l->u.exp_not);
883     return (!res);
884   }
885   case 3 : { 
886     unsigned int cursor = 0;
887     xbt_propositional_symbol_t p = NULL;
888     int_f_void_t f;
889     xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
890       if(strcmp(p->pred, l->u.predicat) == 0){
891         f = (int_f_void_t)p->function;
892         return (*f)();
893       }
894     }
895     return -1;
896   }
897   case 4 : {
898     return 2;
899   }
900   default : 
901     return -1;
902   }
903 }
904
905
906 /********************* Double-DFS stateless *******************/
907
908 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
909   xbt_free(pair->graph_state->proc_status);
910   xbt_free(pair->graph_state);
911   xbt_free(pair);
912 }
913
914 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
915   mc_pair_stateless_t p = NULL;
916   p = xbt_new0(s_mc_pair_stateless_t, 1);
917   p->automaton_state = st;
918   p->graph_state = sg;
919   p->requests = r;
920   mc_stats_pair->expanded_pairs++;
921   return p;
922 }
923
924 void MC_ddfs_init(void){
925
926   XBT_DEBUG("**************************************************");
927   XBT_DEBUG("Double-DFS init");
928   XBT_DEBUG("**************************************************");
929
930   mc_pair_stateless_t mc_initial_pair = NULL;
931   mc_state_t initial_graph_state = NULL;
932   smx_process_t process; 
933
934  
935   MC_wait_for_requests();
936
937   MC_SET_RAW_MEM;
938
939   initial_graph_state = MC_state_pair_new();
940   xbt_swag_foreach(process, simix_global->process_list){
941     if(MC_process_is_enabled(process)){
942       MC_state_interleave_process(initial_graph_state, process);
943     }
944   }
945
946   reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
947   //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
948   //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
949   visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
950   successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
951
952   /* Save the initial state */
953   initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
954   MC_take_snapshot_liveness(initial_snapshot_liveness);
955
956   MC_UNSET_RAW_MEM; 
957
958   unsigned int cursor = 0;
959   xbt_state_t state;
960
961   xbt_dynar_foreach(automaton->states, cursor, state){
962     if(state->type == -1){
963       
964       MC_SET_RAW_MEM;
965       mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
966       xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
967       MC_UNSET_RAW_MEM;
968       
969       if(cursor != 0){
970         MC_restore_snapshot(initial_snapshot_liveness);
971         MC_UNSET_RAW_MEM;
972       }
973
974       MC_ddfs(0);
975
976     }else{
977       if(state->type == 2){
978       
979         MC_SET_RAW_MEM;
980         mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
981         xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
982         MC_UNSET_RAW_MEM;
983
984         set_pair_reached(state);
985         //set_pair_reached_hash(state);
986
987         if(cursor != 0){
988           MC_restore_snapshot(initial_snapshot_liveness);
989           MC_UNSET_RAW_MEM;
990         }
991         
992         MC_ddfs(1);
993         
994       }
995     }
996   } 
997
998 }
999
1000
1001 void MC_ddfs(int search_cycle){
1002
1003   smx_process_t process;
1004   mc_pair_stateless_t current_pair = NULL;
1005
1006   if(xbt_fifo_size(mc_stack_liveness) == 0)
1007     return;
1008
1009
1010   /* Get current pair */
1011   current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
1012
1013   /* Update current state in buchi automaton */
1014   automaton->current_state = current_pair->automaton_state;
1015
1016  
1017   XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
1018   XBT_DEBUG("Pair : graph=%p, automaton=%p(%s), %u interleave", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id, MC_state_interleave_size(current_pair->graph_state));
1019  
1020   mc_stats_pair->visited_pairs++;
1021
1022   //sleep(1);
1023
1024   int value;
1025   mc_state_t next_graph_state = NULL;
1026   smx_simcall_t req = NULL;
1027   char *req_str;
1028
1029   xbt_transition_t transition_succ;
1030   unsigned int cursor = 0;
1031   int res;
1032
1033   mc_pair_stateless_t next_pair = NULL;
1034   mc_pair_stateless_t pair_succ;
1035
1036   if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
1037
1038     //set_pair_visited(current_pair->automaton_state, search_cycle);
1039     set_pair_visited_hash(current_pair->automaton_state, search_cycle);
1040
1041     //XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
1042     XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
1043
1044     if(current_pair->requests > 0){
1045
1046       while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
1047    
1048         /* Debug information */
1049         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
1050           req_str = MC_request_to_string(req, value);
1051           XBT_DEBUG("Execute: %s", req_str);
1052           xbt_free(req_str);
1053         }
1054
1055         MC_state_set_executed_request(current_pair->graph_state, req, value);   
1056     
1057         /* Answer the request */
1058         SIMIX_simcall_pre(req, value);
1059
1060         /* Wait for requests (schedules processes) */
1061         MC_wait_for_requests();
1062
1063
1064         MC_SET_RAW_MEM;
1065
1066         /* Create the new expanded graph_state */
1067         next_graph_state = MC_state_pair_new();
1068
1069         /* Get enabled process and insert it in the interleave set of the next graph_state */
1070         xbt_swag_foreach(process, simix_global->process_list){
1071           if(MC_process_is_enabled(process)){
1072             MC_state_interleave_process(next_graph_state, process);
1073           }
1074         }
1075
1076         xbt_dynar_reset(successors);
1077
1078         MC_UNSET_RAW_MEM;
1079
1080
1081         cursor= 0;
1082         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1083
1084           res = MC_automaton_evaluate_label(transition_succ->label);
1085
1086           if(res == 1){ // enabled transition in automaton
1087             MC_SET_RAW_MEM;
1088             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1089             xbt_dynar_push(successors, &next_pair);
1090             MC_UNSET_RAW_MEM;
1091           }
1092
1093         }
1094
1095         cursor = 0;
1096    
1097         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1098       
1099           res = MC_automaton_evaluate_label(transition_succ->label);
1100         
1101           if(res == 2){ // true transition in automaton
1102             MC_SET_RAW_MEM;
1103             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1104             xbt_dynar_push(successors, &next_pair);
1105             MC_UNSET_RAW_MEM;
1106           }
1107
1108         }
1109
1110         cursor = 0; 
1111         
1112         xbt_dynar_foreach(successors, cursor, pair_succ){
1113
1114           if(search_cycle == 1){
1115
1116             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
1117                       
1118               if(reached(pair_succ->automaton_state)){
1119                 //if(reached_hash(pair_succ->automaton_state)){
1120               
1121                 XBT_DEBUG("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
1122
1123                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1124                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
1125                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1126                 XBT_INFO("Counter-example that violates formula :");
1127                 MC_show_stack_liveness(mc_stack_liveness);
1128                 MC_dump_stack_liveness(mc_stack_liveness);
1129                 MC_print_statistics_pairs(mc_stats_pair);
1130                 exit(0);
1131
1132               }else{
1133
1134                 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1135               
1136                 set_pair_reached(pair_succ->automaton_state);
1137                 //set_pair_reached_hash(pair_succ->automaton_state);
1138
1139                 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1140                 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1141
1142                 MC_SET_RAW_MEM;
1143                 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1144                 MC_UNSET_RAW_MEM;
1145                 
1146                 MC_ddfs(search_cycle);
1147
1148               }
1149
1150             }else{
1151
1152               if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1153                 //if(!visited(pair_succ->automaton_state, search_cycle)){
1154                 
1155                 MC_SET_RAW_MEM;
1156                 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1157                 MC_UNSET_RAW_MEM;
1158                 
1159                 MC_ddfs(search_cycle);
1160                 
1161               }else{
1162
1163                 XBT_DEBUG("Next pair already visited ! ");
1164
1165               }
1166               
1167             }
1168
1169           }else{
1170           
1171             if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1172
1173               XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1174             
1175               set_pair_reached(pair_succ->automaton_state); 
1176               //set_pair_reached_hash(pair_succ->automaton_state);
1177
1178               search_cycle = 1;
1179
1180               XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1181               //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1182
1183             }
1184
1185             if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1186               //if(!visited(pair_succ->automaton_state, search_cycle)){
1187               
1188               MC_SET_RAW_MEM;
1189               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1190               MC_UNSET_RAW_MEM;
1191               
1192               MC_ddfs(search_cycle);
1193               
1194             }else{
1195
1196               XBT_DEBUG("Next pair already visited ! ");
1197
1198             }
1199
1200           }
1201
1202          
1203           /* Restore system before checking others successors */
1204           if(cursor != (xbt_dynar_length(successors) - 1))
1205             MC_replay_liveness(mc_stack_liveness, 1);
1206         
1207           
1208         }
1209
1210         if(MC_state_interleave_size(current_pair->graph_state) > 0){
1211           XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
1212           MC_replay_liveness(mc_stack_liveness, 0);
1213         }
1214       }
1215
1216  
1217     }else{  /*No request to execute, search evolution in Büchi automaton */
1218
1219       MC_SET_RAW_MEM;
1220
1221       /* Create the new expanded graph_state */
1222       next_graph_state = MC_state_pair_new();
1223
1224       xbt_dynar_reset(successors);
1225
1226       MC_UNSET_RAW_MEM;
1227
1228
1229       cursor= 0;
1230       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1231
1232         res = MC_automaton_evaluate_label(transition_succ->label);
1233
1234         if(res == 1){ // enabled transition in automaton
1235           MC_SET_RAW_MEM;
1236           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1237           xbt_dynar_push(successors, &next_pair);
1238           MC_UNSET_RAW_MEM;
1239         }
1240
1241       }
1242
1243       cursor = 0;
1244    
1245       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1246       
1247         res = MC_automaton_evaluate_label(transition_succ->label);
1248         
1249         if(res == 2){ // true transition in automaton
1250           MC_SET_RAW_MEM;
1251           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1252           xbt_dynar_push(successors, &next_pair);
1253           MC_UNSET_RAW_MEM;
1254         }
1255
1256       }
1257
1258       cursor = 0; 
1259      
1260       xbt_dynar_foreach(successors, cursor, pair_succ){
1261
1262         if(search_cycle == 1){
1263
1264           if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
1265
1266             if(reached(pair_succ->automaton_state)){
1267               //if(reached_hash(pair_succ->automaton_state)){
1268
1269               XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1270
1271               XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1272               XBT_INFO("|             ACCEPTANCE CYCLE            |");
1273               XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1274               XBT_INFO("Counter-example that violates formula :");
1275               MC_show_stack_liveness(mc_stack_liveness);
1276               MC_dump_stack_liveness(mc_stack_liveness);
1277               MC_print_statistics_pairs(mc_stats_pair);
1278               exit(0);
1279
1280             }else{
1281
1282               XBT_DEBUG("Next pair (depth = %d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1283               
1284               set_pair_reached(pair_succ->automaton_state);
1285               //set_pair_reached_hash(pair_succ->automaton_state);
1286                 
1287               XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1288               //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1289
1290               MC_SET_RAW_MEM;
1291               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1292               MC_UNSET_RAW_MEM;
1293               
1294               MC_ddfs(search_cycle);
1295
1296             }
1297
1298           }else{
1299
1300             if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1301               //if(!visited(pair_succ->automaton_state, search_cycle)){
1302
1303               MC_SET_RAW_MEM;
1304               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1305               MC_UNSET_RAW_MEM;
1306               
1307               MC_ddfs(search_cycle);
1308               
1309             }else{
1310
1311               XBT_DEBUG("Next pair already visited ! ");
1312
1313             }
1314           }
1315             
1316
1317         }else{
1318             
1319           if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1320
1321             set_pair_reached(pair_succ->automaton_state);
1322             //set_pair_reached_hash(pair_succ->automaton_state);
1323                     
1324             search_cycle = 1;
1325
1326             XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1327             //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1328
1329           }
1330
1331           if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1332             //if(!visited(pair_succ->automaton_state, search_cycle)){
1333
1334             MC_SET_RAW_MEM;
1335             xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1336             MC_UNSET_RAW_MEM;
1337             
1338             MC_ddfs(search_cycle);
1339             
1340           }else{
1341
1342             XBT_DEBUG("Next pair already visited ! ");
1343
1344           }
1345
1346         }
1347
1348         /* Restore system before checking others successors */
1349         if(cursor != xbt_dynar_length(successors) - 1)
1350           MC_replay_liveness(mc_stack_liveness, 1);
1351
1352          
1353       }
1354            
1355     }
1356     
1357   }else{
1358     
1359     XBT_DEBUG("Max depth reached");
1360
1361   }
1362
1363   if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1364     XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1365   }else{
1366     XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1367   }
1368
1369   
1370   MC_SET_RAW_MEM;
1371   xbt_fifo_shift(mc_stack_liveness);
1372   if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1373     xbt_dynar_pop(reached_pairs, NULL);
1374     //xbt_dynar_pop(reached_pairs_hash, NULL);
1375   }
1376   MC_UNSET_RAW_MEM;
1377   
1378   
1379
1380 }