1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved. */
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. */
6 #include "mc_private.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
11 "Logging specific to algorithms for liveness properties verification");
13 xbt_dynar_t reached_pairs;
14 xbt_dynar_t visited_pairs;
15 xbt_dynar_t successors;
17 int create_dump(int pair)
19 // Try to enable core dumps
20 struct rlimit core_limit;
21 core_limit.rlim_cur = RLIM_INFINITY;
22 core_limit.rlim_max = RLIM_INFINITY;
24 if(setrlimit(RLIMIT_CORE, &core_limit) < 0)
25 fprintf(stderr, "setrlimit: %s\nWarning: core dumps may be truncated or non-existant\n", strerror(errno));
30 // We are the child process -- run the actual program
35 // An error occurred, shouldn't happen
40 // We are the parent process -- wait for the child process to exit
43 if(WIFSIGNALED(status) && WCOREDUMP(status)){
44 char *core_name = malloc(20);
45 sprintf(core_name,"core_%d", pair);
46 rename("core", core_name);
54 void MC_print_comparison_times_statistics(mc_comparison_times_t ct){
56 XBT_DEBUG("Comparisons done : %d", ct->nb_comparisons);
58 double total, min, max;
61 if(xbt_dynar_length(ct->chunks_used_comparison_times) > 0){
65 min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
66 while(cursor < xbt_dynar_length(ct->chunks_used_comparison_times) - 1){
67 total += xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
68 if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) > max)
69 max = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
70 if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) < min)
71 min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
74 XBT_DEBUG("Chunks used comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->chunks_used_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->chunks_used_comparison_times), max, min);
77 if(xbt_dynar_length(ct->stacks_sizes_comparison_times) > 0){
81 min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
82 while(cursor < xbt_dynar_length(ct->stacks_sizes_comparison_times) - 1){
83 total += xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
84 if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) > max)
85 max = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
86 if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) < min)
87 min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
90 XBT_DEBUG("Stacks sizes comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_sizes_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_sizes_comparison_times), max, min);
93 if(xbt_dynar_length(ct->program_data_segment_comparison_times) > 0){
97 min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
98 while(cursor < xbt_dynar_length(ct->program_data_segment_comparison_times) - 1){
99 total += xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
100 if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) > max)
101 max = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
102 if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) < min)
103 min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
106 XBT_DEBUG("Program data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->program_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->program_data_segment_comparison_times), max, min);
109 if(xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) > 0){
113 min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
114 while(cursor < xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) - 1){
115 total += xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
116 if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) > max)
117 max = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
118 if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) < min)
119 min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
122 XBT_DEBUG("Libsimgrid data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), max, min);
125 if(xbt_dynar_length(ct->heap_comparison_times) > 0){
129 min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
130 while(cursor < xbt_dynar_length(ct->heap_comparison_times) - 1){
131 total += xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
132 if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) > max)
133 max = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
134 if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) < min)
135 min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
138 XBT_DEBUG("Heap comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->heap_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->heap_comparison_times), max, min);
141 if(xbt_dynar_length(ct->stacks_comparison_times) > 0){
145 min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
146 while(cursor < xbt_dynar_length(ct->stacks_comparison_times) - 1){
147 total += xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
148 if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) > max)
149 max = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
150 if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) < min)
151 min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
154 XBT_DEBUG("Stacks comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_comparison_times), max, min);
157 if(xbt_dynar_length(ct->snapshot_comparison_times) > 0){
161 min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
162 while(cursor < xbt_dynar_length(ct->snapshot_comparison_times) - 1){
163 total += xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
164 if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) > max)
165 max = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
166 if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) < min)
167 min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
170 XBT_DEBUG("Snapshot comparison (Whole funnel) -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->snapshot_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->snapshot_comparison_times), max, min);
175 mc_comparison_times_t new_comparison_times(){
176 mc_comparison_times_t ct = NULL;
177 ct = xbt_new0(s_mc_comparison_times_t, 1);
178 ct->nb_comparisons = 0;
179 ct->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
180 ct->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
181 ct->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
182 ct->program_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
183 ct->libsimgrid_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
184 ct->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
185 ct->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
189 int reached(xbt_state_t st){
191 int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
195 mc_pair_reached_t new_pair = NULL;
196 new_pair = xbt_new0(s_mc_pair_reached_t, 1);
197 new_pair->nb = xbt_dynar_length(reached_pairs) + 1;
198 new_pair->automaton_state = st;
199 new_pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
200 new_pair->comparison_times = new_comparison_times();
201 new_pair->system_state = MC_take_snapshot();
203 /* Get values of propositional symbols */
206 unsigned int cursor = 0;
207 xbt_propositional_symbol_t ps = NULL;
208 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
209 f = (int_f_void_t)ps->function;
211 xbt_dynar_push_as(new_pair->prop_ato, int, res);
216 if(xbt_dynar_is_empty(reached_pairs)/* || !compare*/){
219 /* New pair reached */
220 xbt_dynar_push(reached_pairs, &new_pair);
233 mc_pair_reached_t pair_test = NULL;
235 xbt_dynar_foreach(reached_pairs, cursor, pair_test){
236 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug))
237 XBT_DEBUG("****** Pair reached #%d ******", pair_test->nb);
238 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
239 if(propositional_symbols_compare_value(pair_test->prop_ato, new_pair->prop_ato) == 0){
240 if(snapshot_compare(new_pair->system_state, pair_test->system_state, new_pair->comparison_times, pair_test->comparison_times) == 0){
250 XBT_DEBUG("Different values of propositional symbols");
253 XBT_DEBUG("Different automaton state");
255 if(pair_test->comparison_times != NULL && XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
256 XBT_DEBUG("*** Comparison times statistics ***");
257 MC_print_comparison_times_statistics(pair_test->comparison_times);
261 /* New pair reached */
262 xbt_dynar_push(reached_pairs, &new_pair);
277 void set_pair_reached(xbt_state_t st){
279 int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
283 mc_pair_reached_t pair = NULL;
284 pair = xbt_new0(s_mc_pair_reached_t, 1);
285 pair->nb = xbt_dynar_length(reached_pairs) + 1;
286 pair->automaton_state = st;
287 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
288 pair->comparison_times = new_comparison_times();
289 pair->system_state = MC_take_snapshot();
291 /* Get values of propositional symbols */
292 unsigned int cursor = 0;
293 xbt_propositional_symbol_t ps = NULL;
297 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
298 f = (int_f_void_t)ps->function;
300 xbt_dynar_push_as(pair->prop_ato, int, res);
303 xbt_dynar_push(reached_pairs, &pair);
312 int visited(xbt_state_t st){
314 if(_surf_mc_visited == 0)
317 int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
321 mc_pair_visited_t new_pair = NULL;
322 new_pair = xbt_new0(s_mc_pair_visited_t, 1);
323 new_pair->automaton_state = st;
324 new_pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
325 new_pair->system_state = MC_take_snapshot();
327 /* Get values of propositional symbols */
330 unsigned int cursor = 0;
331 xbt_propositional_symbol_t ps = NULL;
332 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
333 f = (int_f_void_t)ps->function;
335 xbt_dynar_push_as(new_pair->prop_ato, int, res);
340 if(xbt_dynar_is_empty(visited_pairs)){
343 /* New pair visited */
344 xbt_dynar_push(visited_pairs, &new_pair);
357 mc_pair_visited_t pair_test = NULL;
359 xbt_dynar_foreach(visited_pairs, cursor, pair_test){
360 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug))
361 XBT_DEBUG("****** Pair visited #%d ******", cursor + 1);
362 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
363 if(propositional_symbols_compare_value(pair_test->prop_ato, new_pair->prop_ato) == 0){
364 if(snapshot_compare(new_pair->system_state, pair_test->system_state, NULL, NULL) == 0){
373 XBT_DEBUG("Different values of propositional symbols");
376 XBT_DEBUG("Different automaton state");
380 if(xbt_dynar_length(visited_pairs) == _surf_mc_visited){
381 xbt_dynar_remove_at(visited_pairs, 0, NULL);
384 /* New pair visited */
385 xbt_dynar_push(visited_pairs, &new_pair);
397 void MC_pair_delete(mc_pair_t pair){
398 xbt_free(pair->graph_state->proc_status);
399 xbt_free(pair->graph_state);
405 int MC_automaton_evaluate_label(xbt_exp_label_t l){
409 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
410 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
411 return (left_res || right_res);
414 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
415 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
416 return (left_res && right_res);
419 int res = MC_automaton_evaluate_label(l->u.exp_not);
423 unsigned int cursor = 0;
424 xbt_propositional_symbol_t p = NULL;
426 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p){
427 if(strcmp(p->pred, l->u.predicat) == 0){
428 f = (int_f_void_t)p->function;
443 /********************* Double-DFS stateless *******************/
445 void pair_visited_free(mc_pair_visited_t pair){
447 pair->automaton_state = NULL;
448 xbt_dynar_free(&(pair->prop_ato));
449 MC_free_snapshot(pair->system_state);
454 void pair_visited_free_voidp(void *p){
455 pair_visited_free((mc_pair_visited_t) * (void **) p);
458 void pair_stateless_free(mc_pair_stateless_t pair){
459 xbt_free(pair->graph_state->system_state);
460 xbt_free(pair->graph_state->proc_status);
461 xbt_free(pair->graph_state);
465 void pair_stateless_free_voidp(void *p){
466 pair_stateless_free((mc_pair_stateless_t) * (void **) p);
469 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
470 mc_pair_stateless_t p = NULL;
471 p = xbt_new0(s_mc_pair_stateless_t, 1);
472 p->automaton_state = st;
475 mc_stats_pair->expanded_pairs++;
479 void pair_reached_free(mc_pair_reached_t pair){
481 pair->automaton_state = NULL;
482 xbt_dynar_free(&(pair->prop_ato));
483 if(pair->comparison_times != NULL){
484 xbt_dynar_free(&(pair->comparison_times->snapshot_comparison_times));
485 xbt_dynar_free(&(pair->comparison_times->chunks_used_comparison_times));
486 xbt_dynar_free(&(pair->comparison_times->stacks_sizes_comparison_times));
487 xbt_dynar_free(&(pair->comparison_times->program_data_segment_comparison_times));
488 xbt_dynar_free(&(pair->comparison_times->libsimgrid_data_segment_comparison_times));
489 xbt_dynar_free(&(pair->comparison_times->heap_comparison_times));
490 xbt_dynar_free(&(pair->comparison_times->stacks_comparison_times));
492 MC_free_snapshot(pair->system_state);
497 void pair_reached_free_voidp(void *p){
498 pair_reached_free((mc_pair_reached_t) * (void **) p);
501 void MC_ddfs_init(void){
503 initial_state_liveness->raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
505 XBT_DEBUG("**************************************************");
506 XBT_DEBUG("Double-DFS init");
507 XBT_DEBUG("**************************************************");
509 mc_pair_stateless_t mc_initial_pair = NULL;
510 mc_state_t initial_graph_state = NULL;
511 smx_process_t process;
514 MC_wait_for_requests();
518 initial_graph_state = MC_state_pair_new();
519 xbt_swag_foreach(process, simix_global->process_list){
520 if(MC_process_is_enabled(process)){
521 MC_state_interleave_process(initial_graph_state, process);
525 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), pair_reached_free_voidp);
526 visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), pair_visited_free_voidp);
527 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
529 /* Save the initial state */
530 initial_state_liveness->snapshot = MC_take_snapshot();
534 unsigned int cursor = 0;
537 xbt_dynar_foreach(_mc_property_automaton->states, cursor, state){
538 if(state->type == -1){
541 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
542 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
546 MC_restore_snapshot(initial_state_liveness->snapshot);
553 if(state->type == 2){
556 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
557 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
560 set_pair_reached(state);
563 MC_restore_snapshot(initial_state_liveness->snapshot);
573 if(initial_state_liveness->raw_mem_set)
582 void MC_ddfs(int search_cycle){
584 //initial_state_liveness->raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
586 smx_process_t process;
587 mc_pair_stateless_t current_pair = NULL;
589 if(xbt_fifo_size(mc_stack_liveness) == 0)
593 /* Get current pair */
594 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
596 /* Update current state in buchi automaton */
597 _mc_property_automaton->current_state = current_pair->automaton_state;
600 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
602 mc_stats_pair->visited_pairs++;
607 mc_state_t next_graph_state = NULL;
608 smx_simcall_t req = NULL;
611 xbt_transition_t transition_succ;
612 unsigned int cursor = 0;
615 mc_pair_stateless_t next_pair = NULL;
616 mc_pair_stateless_t pair_succ;
618 mc_pair_stateless_t remove_pair;
619 mc_pair_reached_t remove_pair_reached;
621 if(xbt_fifo_size(mc_stack_liveness) < _surf_mc_max_depth){
623 if(current_pair->requests > 0){
625 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
627 /* Debug information */
629 req_str = MC_request_to_string(req, value);
630 XBT_DEBUG("Execute: %s", req_str);
633 MC_state_set_executed_request(current_pair->graph_state, req, value);
635 /* Answer the request */
636 SIMIX_simcall_pre(req, value);
638 /* Wait for requests (schedules processes) */
639 MC_wait_for_requests();
643 /* Create the new expanded graph_state */
644 next_graph_state = MC_state_pair_new();
646 /* Get enabled process and insert it in the interleave set of the next graph_state */
647 xbt_swag_foreach(process, simix_global->process_list){
648 if(MC_process_is_enabled(process)){
649 XBT_DEBUG("Process %lu enabled with simcall : %d", process->pid, (&process->simcall)->call);
653 xbt_swag_foreach(process, simix_global->process_list){
654 if(MC_process_is_enabled(process)){
655 MC_state_interleave_process(next_graph_state, process);
659 xbt_dynar_reset(successors);
665 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
667 res = MC_automaton_evaluate_label(transition_succ->label);
669 if(res == 1){ // enabled transition in automaton
671 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
672 xbt_dynar_push(successors, &next_pair);
680 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
682 res = MC_automaton_evaluate_label(transition_succ->label);
684 if(res == 2){ // true transition in automaton
686 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
687 xbt_dynar_push(successors, &next_pair);
695 xbt_dynar_foreach(successors, cursor, pair_succ){
697 if(search_cycle == 1){
699 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
701 if(reached(pair_succ->automaton_state)){
703 XBT_INFO("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
705 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
706 XBT_INFO("| ACCEPTANCE CYCLE |");
707 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
708 XBT_INFO("Counter-example that violates formula :");
709 MC_show_stack_liveness(mc_stack_liveness);
710 MC_dump_stack_liveness(mc_stack_liveness);
711 MC_print_statistics_pairs(mc_stats_pair);
716 if(visited(pair_succ->automaton_state)){
718 XBT_DEBUG("Next pair already visited !");
723 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
725 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
728 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
731 MC_ddfs(search_cycle);
739 if(visited(pair_succ->automaton_state)){
741 XBT_DEBUG("Next pair already visited !");
747 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
750 MC_ddfs(search_cycle);
757 if(visited(pair_succ->automaton_state)){
759 XBT_DEBUG("Next pair already visited !");
764 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
766 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
768 set_pair_reached(pair_succ->automaton_state);
772 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
777 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
780 MC_ddfs(search_cycle);
786 /* Restore system before checking others successors */
787 if(cursor != (xbt_dynar_length(successors) - 1))
788 MC_replay_liveness(mc_stack_liveness, 1);
792 if(MC_state_interleave_size(current_pair->graph_state) > 0){
793 XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
794 MC_replay_liveness(mc_stack_liveness, 0);
801 XBT_DEBUG("No more request to execute in this state, search evolution in Büchi Automaton.");
805 /* Create the new expanded graph_state */
806 next_graph_state = MC_state_pair_new();
808 xbt_dynar_reset(successors);
814 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
816 res = MC_automaton_evaluate_label(transition_succ->label);
818 if(res == 1){ // enabled transition in automaton
820 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
821 xbt_dynar_push(successors, &next_pair);
829 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
831 res = MC_automaton_evaluate_label(transition_succ->label);
833 if(res == 2){ // true transition in automaton
835 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
836 xbt_dynar_push(successors, &next_pair);
844 xbt_dynar_foreach(successors, cursor, pair_succ){
846 if(search_cycle == 1){
848 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
850 if(reached(pair_succ->automaton_state)){
852 XBT_INFO("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
854 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
855 XBT_INFO("| ACCEPTANCE CYCLE |");
856 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
857 XBT_INFO("Counter-example that violates formula :");
858 MC_show_stack_liveness(mc_stack_liveness);
859 MC_dump_stack_liveness(mc_stack_liveness);
860 MC_print_statistics_pairs(mc_stats_pair);
865 XBT_INFO("Next pair (depth = %d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
867 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
870 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
873 MC_ddfs(search_cycle);
880 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
883 MC_ddfs(search_cycle);
890 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
892 set_pair_reached(pair_succ->automaton_state);
896 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
901 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
904 MC_ddfs(search_cycle);
908 /* Restore system before checking others successors */
909 if(cursor != xbt_dynar_length(successors) - 1)
910 MC_replay_liveness(mc_stack_liveness, 1);
918 XBT_WARN("/!\\ Max depth reached ! /!\\ ");
919 if(current_pair->requests > 0){
920 XBT_WARN("/!\\ But, there are still processes to interleave. Model-checker will not be able to ensure the soundness of the verification from now. /!\\ ");
921 XBT_WARN("Notice : the default value of max depth is 1000 but you can change it with cfg=model-check/max_depth:value.");
926 if(xbt_fifo_size(mc_stack_liveness) == _surf_mc_max_depth ){
927 XBT_DEBUG("Pair (depth = %d) shifted in stack, maximum depth reached", xbt_fifo_size(mc_stack_liveness) );
929 XBT_DEBUG("Pair (depth = %d) shifted in stack", xbt_fifo_size(mc_stack_liveness) );
934 remove_pair = xbt_fifo_shift(mc_stack_liveness);
935 xbt_fifo_remove(mc_stack_liveness, remove_pair);
937 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
938 remove_pair_reached = xbt_dynar_pop_as(reached_pairs, mc_pair_reached_t);
939 pair_reached_free(remove_pair_reached);
940 remove_pair_reached = NULL;
944 /*if(initial_state_liveness->raw_mem_set)