How to fix Glib warnings or errors with GDB by Olivier on 18/02/2017 18:37

After adding support for Bluez5 in the latest version of gattlib, the Glib warning message GLib-WARNING **: Invalid file descriptor was printed every time we were closing a gattlib connection.
Even if the error warning was looking harmless, a warning message should never occurs after a normal operation.

Here are the following steps to fix a Glib warning or error:

  1. Ensure debug support is present in the gattlib based applications:

    cd <gattlib_root>
    mkdir build && cd build
    cmake -DCMAKE_BUILD_TYPE=Debug ..
  2. Tell Glib library to treat warnings as error:

    export G_DEBUG=fatal_warnings
  3. Debug one of the gattlib examples using gdb:

    gdb ./examples/read_write/read_write
  4. Start the program and pass its arguments:

    (gdb) run  DA:94:40:95:E0:87 read 0x2a38
    Starting program: /home/olivier/gattlib/build/examples/read_write/read_write DA:94:40:95:E0:87 read 0x2a38
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/i386-linux-gnu/".
    [New Thread 0xb7bdab40 (LWP 3594)]
    Read UUID completed: 03 
    (process:3590): GLib-WARNING **: Invalid file descriptor.
    Thread 1 "read_w" received signal SIGTRAP, Trace/breakpoint trap.
    0xb7cbc749 in g_logv () from /lib/i386-linux-gnu/
  5. Inspect the callstack:

    (gdb) where
    #0  0xb7cbc749 in g_logv () from /lib/i386-linux-gnu/
    #1  0xb7cbc805 in g_log () from /lib/i386-linux-gnu/
    #2  0xb7ca7c28 in g_io_channel_error_from_errno () from /lib/i386-linux-gnu/
    #3  0xb7cfcbee in ?? () from /lib/i386-linux-gnu/
    #4  0xb7ca84ea in g_io_channel_shutdown () from /lib/i386-linux-gnu/
    #5  0xb7ca86cd in g_io_channel_unref () from /lib/i386-linux-gnu/
    #6  0xb7fb988c in io_destroy (io=0xb7200fe8) at /home/olivier/gattlib/bluez5/src/shared/io-glib.c:132
    #7  0xb7fa90cb in bt_att_free (att=0xb7202a00) at /home/olivier/gattlib/bluez5/src/shared/att.c:955
    #8  0xb7fa94be in bt_att_unref (att=0xb7202a00) at /home/olivier/gattlib/bluez5/src/shared/att.c:1065
    #9  0xb7f7f224 in g_attrib_unref (attrib=0xb7200fc0) at /home/olivier/gattlib/bluez5/attrib/gattrib.c:195
    #10 0xb7f7932c in gattlib_disconnect (connection=0x804cef8) at /home/olivier/gattlib/src/gattlib_connect.c:359
    #11 0x08048c72 in main (argc=4, argv=0xbfffee74) at /home/olivier/gattlib/examples/read_write/read_write.c:93
  6. Fix the issue!

Anonymous on 15/07/2018 05:02
<a href=>cheap viagra uk</a>
non prescription viagra usa
cheap viagra uk

Login to comment Comment as anonymous