From 9ad062b2475f07ae591712cd37caf99003eed07b Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sat, 9 Apr 2011 17:33:42 +0200 Subject: [PATCH] Fix two spurious segfaults in test cases for the Python interface. * wrap/python/tests/setxor.py, wrap/python/tests/bddnqueen.py: Clean all used bdd variables before calling bdd_done(), so that bdd_delref() is never called after bdd_done(). In NDEBUG builds, bdd_delref() does not check whether the BuDDy is running or not, and calling it after bdd_done() will crash. --- ChangeLog | 10 ++++++++++ wrap/python/tests/bddnqueen.py | 14 ++++++++++---- wrap/python/tests/setxor.py | 9 +++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 606ca3ecc..8797f2da5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-04-09 Alexandre Duret-Lutz + + Fix two spurious segfaults in test cases for the Python interface. + + * wrap/python/tests/setxor.py, wrap/python/tests/bddnqueen.py: + Clean all used bdd variables before calling bdd_done(), so that + bdd_delref() is never called after bdd_done(). In NDEBUG builds, + bdd_delref() does not check whether the BuDDy is running or not, + and calling it after bdd_done() will crash. + 2011-04-09 Alexandre Duret-Lutz * HACKING: Add an example for using callgrind. diff --git a/wrap/python/tests/bddnqueen.py b/wrap/python/tests/bddnqueen.py index 559055630..12209fb11 100755 --- a/wrap/python/tests/bddnqueen.py +++ b/wrap/python/tests/bddnqueen.py @@ -1,7 +1,9 @@ -# -*- mode: python; coding: iso-8859-1 -*- -# Copyright (C) 2003, 2004, 2010 Laboratoire d'Informatique de Paris 6 (LIP6), -# département Systèmes Répartis Coopératifs (SRC), Université Pierre -# et Marie Curie. +# -*- mode: python; coding: utf-8 -*- +# Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement +# de l'EPITA. +# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 +# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université +# Pierre et Marie Curie. # # This file is part of Spot, a model checking library. # @@ -97,4 +99,8 @@ solution = bdd_satone(queen) bdd_printset(solution) print +# Cleanup all BDD variables before calling bdd_done(), otherwise +# bdd_delref will be called after bdd_done() and this is unsafe in +# optimized builds. +X = e = queen = solution = 0 bdd_done() diff --git a/wrap/python/tests/setxor.py b/wrap/python/tests/setxor.py index e55d9914a..37754b775 100755 --- a/wrap/python/tests/setxor.py +++ b/wrap/python/tests/setxor.py @@ -1,5 +1,6 @@ -# -*- mode: python; coding: iso-8859-1 -*- -# Copyright (C) 2010 Laboratoire de Recherche et Développement de l'EPITA. +# -*- mode: python; coding: utf-8 -*- +# Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement +# de l'EPITA. # # This file is part of Spot, a model checking library. # @@ -43,4 +44,8 @@ e = V[0] & V[1] & -V[2] & -V[3] & V[4] assert(e == bdd_setxor(a,d)) assert(e == bdd_setxor(d,a)) +# Cleanup all BDD variables before calling bdd_done(), otherwise +# bdd_delref will be called after bdd_done() and this is unsafe in +# optimized builds. +V = a = b = c = d = e = 0; bdd_done()