From b80bfc6208b6257ba7b51c6ef3eeece7377e7696 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 27 Mar 2024 19:14:24 +0000 Subject: [PATCH] configure.ac: build with `-DFMT_EXCEPTIONS=0` Coverity flags some functions marked `noexcept` that call `fmt::format`, since `fmt::format` can throw `fmt::format_error` exceptions. We're not interested in handling format errors at runtime, we'd rather just get a crash and fix it. Build the entire project (including `libfmt.la`) with `-DFMT_EXCEPTIONS=0` to make {fmt} crash instead of throw, should a format error occur. Tested by introducing a format error somewhere and running to it. The result is very pretty: $ tests/plugins/flt.utils.muxer/test-clock-compatibility 1..150 /home/smarchi/src/babeltrace/src/cpp-common/vendor/fmt/format-inl.h:40: assertion failed: invalid format stringterminate called without an active exception [1] 1189949 IOT instruction tests/plugins/flt.utils.muxer/test-clock-compatibility Change-Id: Ibcb0104a6bf644b025112d0b35e4fbe622c20be9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12194 Reviewed-by: Philippe Proulx Reviewed-by: Michael Jeanson Tested-by: jenkins --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index fa21a881..799df2f7 100644 --- a/configure.ac +++ b/configure.ac @@ -798,6 +798,11 @@ AC_SUBST(AM_CPPFLAGS) # Add glib to global link libs LIBS="$LIBS $GLIB_LIBS" +# Disable exceptions for the {fmt} library. This means, for example, that a +# format error will result in an assertion failure (instead of throwing an +# `fmt::format_error` exception). +AC_DEFINE_UNQUOTED([FMT_EXCEPTIONS], 0, [Disable {fmt} exceptions.]) + # Abuse autoconf's AC_ARG_PROGRAM output variable 'program_transform_name' # to rename babeltrace2.bin to babeltrace2 at install time. program_transform_name="s&babeltrace2\.bin&babeltrace2&;$program_transform_name" -- 2.34.1