From 60611c1ae7019e9013ef0d66f1e45b4e0f14d0de Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Thu, 27 Jun 2024 07:50:41 +0200 Subject: [PATCH] Fix crash in CPAchecker's tool-info module We have a heuristic that checks if CPAchecker is used from source but misses a rebuild. This would crash if broken symlinks or other file-access problems occur. As it is just an optional feature, we can ignore such problems and print a warning. An example where this happened was for example system-wide installation of CPAchecker with the executable being /usr/bin/cpachecker and /usr/src existing. --- benchexec/tools/cpachecker.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/benchexec/tools/cpachecker.py b/benchexec/tools/cpachecker.py index 3a30c6b75..07044226f 100644 --- a/benchexec/tools/cpachecker.py +++ b/benchexec/tools/cpachecker.py @@ -69,16 +69,21 @@ def executable(self, tool_locator): # If this is a source checkout of CPAchecker, we heuristically check that # sources are not newer than binaries (cpachecker.jar or files in bin/). - if os.path.isdir(src_dir): - src_mtime = self._find_newest_mtime(src_dir) - - if os.path.isfile(jar_file): - if src_mtime > os.stat(jar_file).st_mtime: - sys.exit("CPAchecker JAR is not uptodate, run 'ant jar'!") - - elif os.path.isdir(cls_dir): - if src_mtime > self._find_newest_mtime(cls_dir): - sys.exit("CPAchecker build is not uptodate, run 'ant'!") + try: + if os.path.isdir(src_dir): + src_mtime = self._find_newest_mtime(src_dir) + + if os.path.isfile(jar_file): + if src_mtime > os.stat(jar_file).st_mtime: + sys.exit("CPAchecker JAR is not uptodate, run 'ant jar'!") + + elif os.path.isdir(cls_dir): + if src_mtime > self._find_newest_mtime(cls_dir): + sys.exit("CPAchecker build is not uptodate, run 'ant'!") + except OSError as e: + logging.warning( + "Could not determine whether CPAchecker needs to be rebuilt: %s", e + ) return executable