From 8ec6ea838de92b0489b2c319f3c9246a1de00697 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 30 Jul 2019 15:30:36 +0200 Subject: [PATCH] twa_graph: fix precondition on set_init_state Fixes #391. * spot/twa/twagraph.hh: Here. * tests/core/dualize.test, tests/python/except.py: New tests. * NEWS: Mention the bug. --- NEWS | 6 +++- spot/twa/twagraph.hh | 5 ++- tests/core/dualize.test | 79 ++++++++++++++++++++++++++++++++++++++++- tests/python/except.py | 21 ++++++++++- 4 files changed, 107 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 148b1f905..7707c4312 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ New in spot 2.8.1.dev (not yet released) - Nothing yet. + Bugs fixed: + + - Calling "autfilt --dualize" on an alternating automaton with + transition-based acceptance and universal initial states would + fail with "set_init_state() called with nonexisting state". New in spot 2.8.1 (2019-07-18) diff --git a/spot/twa/twagraph.hh b/spot/twa/twagraph.hh index fcbdb97d8..090736096 100644 --- a/spot/twa/twagraph.hh +++ b/spot/twa/twagraph.hh @@ -285,7 +285,10 @@ namespace spot void set_init_state(state_num s) { - if (SPOT_UNLIKELY(s >= num_states())) + bool univ = is_univ_dest(s); + if (SPOT_UNLIKELY((!univ && s >= num_states()) + // univ destinations have at least length 2. + || (univ && 2 + ~s >= g_.dests_vector().size()))) throw std::invalid_argument ("set_init_state() called with nonexisting state"); init_number_ = s; diff --git a/tests/core/dualize.test b/tests/core/dualize.test index 58ffa68d7..7e66c3b8f 100755 --- a/tests/core/dualize.test +++ b/tests/core/dualize.test @@ -1,6 +1,6 @@ #!/bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2017 Laboratoire de Recherche et +# Copyright (C) 2017, 2019 Laboratoire de Recherche et # Développement de l'Epita (LRDE). # # This file is part of Spot, a model checking library. @@ -65,3 +65,80 @@ EOF run 0 autfilt input1 --dualize --hoaf=t | tee stdout diff stdout expected rm input1 expected stdout + +# issue #391 +cat >input2 <output2 +cat >expected2<