[gnome-settings-daemon/wip/claudio/CI: 3/3] power: Add memory sanitization workaround to power enums helper



commit 9e070fc5da9d0a020ef5f5b4da84b9cbce73cbd7
Author: Benjamin Berg <bberg redhat com>
Date:   Tue Feb 5 19:07:16 2019 +0100

    power: Add memory sanitization workaround to power enums helper
    
    For some reason we get an error when calling g_print. This works around
    the following build error:
    
    Uninitialized bytes in __interceptor_fopen64 at offset 3 inside [0x702000000160, 18)
    ==30133==WARNING: MemorySanitizer: use-of-uninitialized-value
        #0 0x7f9e3205ab75 in _g_locale_get_charset_aliases.part.0 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/libcharset/localcharset.c:141:38
        #1 0x7f9e3205afc4 in _g_locale_get_charset_aliases 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/libcharset/localcharset.c:448:3
        #2 0x7f9e3205afc4 in _g_locale_charset_unalias 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/libcharset/localcharset.c:448:18
        #3 0x7f9e31feb569 in g_utf8_get_charset_internal 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/gcharset.c:119:13
        #4 0x7f9e31feb569 in g_get_charset 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/gcharset.c:204:24
        #5 0x7f9e3201a007 in g_print 
/home/benjamin/.cache/jhbuild/build/glib/../../../../Projects/jhbuild/checkout/glib/glib/gmessages.c:3189:11
        #6 0x494488 in output_flags_values 
/home/benjamin/Projects/jhbuild/checkout/gnome-settings-daemon/_build/../plugins/power/gsd-power-enums-update.c:26:3
        #7 0x49432a in main 
/home/benjamin/Projects/jhbuild/checkout/gnome-settings-daemon/_build/../plugins/power/gsd-power-enums-update.c:41:2
        #8 0x7f9e31bb4412 in __libc_start_main (/lib64/libc.so.6+0x24412)
        #9 0x41b33d in _start 
(/home/benjamin/Projects/jhbuild/checkout/gnome-settings-daemon/_build/plugins/power/gsd-power-enums-update+0x41b33d)

 plugins/power/gsd-power-enums-update.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/plugins/power/gsd-power-enums-update.c b/plugins/power/gsd-power-enums-update.c
index bdc4e050..3bc10223 100644
--- a/plugins/power/gsd-power-enums-update.c
+++ b/plugins/power/gsd-power-enums-update.c
@@ -1,6 +1,11 @@
 #include <glib-object.h>
 #include <gsd-power-enums.h>
 
+/* XXX: The following functions use printf, because otherwise there were
+ *      build failures when the building with the memory sanitizer enabled.
+ *      These may be false positives though.
+ */
+
 static void
 output_enum_values (GType class_type)
 {
@@ -10,7 +15,7 @@ output_enum_values (GType class_type)
        eclass = G_ENUM_CLASS (g_type_class_peek (class_type));
        for (i = 0; i < eclass->n_values; i++) {
                GEnumValue *value = &(eclass->values[i]);
-               g_print ("%s = %d;\n", value->value_name, value->value);
+               printf ("%s = %d;\n", value->value_name, value->value);
        }
 }
 
@@ -23,7 +28,7 @@ output_flags_values (GType class_type)
        fclass = G_FLAGS_CLASS (g_type_class_peek (class_type));
        for (i = 0; i < fclass->n_values; i++) {
                GFlagsValue *value = &(fclass->values[i]);
-               g_print ("%s = %d;\n", value->value_name, value->value);
+               printf ("%s = %d;\n", value->value_name, value->value);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]