On Fri, Oct 18, 2019 at 12:16:00PM +0200, Peter Krempa wrote:
On Fri, Oct 18, 2019 at 11:49:05 +0200, Michal Privoznik wrote:These functions don't really abort() on OOM. The fix was merged upstream, but not in the minimal version we require. Provide our own implementation which can be removed once we bump the minimal version. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- v2 of: https://www.redhat.com/archives/libvir-list/2019-October/msg01153.html diff to v1: - moved the code to src/utils/glibcompat.c src/internal.h | 1 + src/libvirt_private.syms | 5 +++++ src/util/Makefile.inc.am | 2 ++ src/util/glibcompat.c | 48 ++++++++++++++++++++++++++++++++++++++++ src/util/glibcompat.h | 31 ++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 src/util/glibcompat.c create mode 100644 src/util/glibcompat.h
+/* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf() + * abort on OOM. It's fixed in glib's upstream. Provide our own + * implementation until the fix get's distributed. */ +char * +vir_g_strdup_printf(const char *msg, ...) +{ + va_list args; + char *ret; + va_start(args, msg); + ret = g_strdup_vprintf(msg, args); + if (!ret) + abort(); + va_end(args); + return ret; +} + + +char * +vir_g_strdup_vprintf(const char *msg, va_list args) +{ + char *ret; + ret = g_strdup_vprintf(msg, args);So this will become vir_g_strdup_vprintf.. thus become infinite recursion.
No problem, we can just turn off the warning: diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 7c86fdd3c6..e531eadc1e 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -127,6 +127,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ dontwarn="$dontwarn -Woverlength-strings" dontwarn="$dontwarn -Wstack-protector" + # Needed for our g_strdup_vprintf workaround + dontwarn="$dontwarn -Winfinite-recursion" + # Get all possible GCC warnings gl_MANYWARN_ALL_GCC([maybewarn]) Jano
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list