configure.ac: build with `-DFMT_EXCEPTIONS=0`
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 27 Mar 2024 19:14:24 +0000 (19:14 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 28 Mar 2024 17:52:05 +0000 (13:52 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12194
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
configure.ac

index fa21a8813509bb698b18457bb28b27d24b127830..799df2f79857250c8d57775b870bd2d06618d3f1 100644 (file)
@@ -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"
This page took 0.025443 seconds and 4 git commands to generate.