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 ..
    make
    
  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/libthread_db.so.1".
    [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/libglib-2.0.so.0
    
  5. Inspect the callstack:

    (gdb) where
    #0  0xb7cbc749 in g_logv () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #1  0xb7cbc805 in g_log () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #2  0xb7ca7c28 in g_io_channel_error_from_errno () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #3  0xb7cfcbee in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #4  0xb7ca84ea in g_io_channel_shutdown () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #5  0xb7ca86cd in g_io_channel_unref () from /lib/i386-linux-gnu/libglib-2.0.so.0
    #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
    (gdb)
    
  6. Fix the issue!

Anonymous on 15/07/2018 05:02
<a href=http://canadian-pharman.com>cheap viagra uk</a>
non prescription viagra usa
cheap viagra uk http://canadian-pharman.com
Anonymous on 25/02/2023 10:42
Hi! Thanks your article. I have a question: how to fix this issue by inspecting the callstack shown above?
Anonymous on 29/04/2023 00:26
Use TS processes to optimize improvements <a href=http://cialiss.buzz>cialis 5mg online</a>
Anonymous on 30/05/2023 00:00
<a href=https://finasterid.sbs>propecia alternative</a> Elroy LhulDQcqacBwqwJ 6 17 2022
Anonymous on 16/09/2023 09:26
https://mnwiki.org/index.php/Purchase_ATIVAN_Online_-_ATIVAN_2mg_5mg_Dosage http://www.forderm.net/bbs/board.php?bo_table=free&wr_id=1232 http://bkr.kr/board_BsrK22/6154347 https://obengdarko.com.gh/forums/users/lavernelett4512/ https://wiki.vie.today/index.php?title=%D0%A3%D0%B4%D0%B7%D0%B5%D0%BB%D1%8C%D0%BD%D1%96%D0%BA:CassieChiodo https://nebenwelten.net/index.php?title=User:LucretiaChapin0 Jarffenzo.com <a href="https://mnwiki.org/index.php/AMBIEN_Purchase_Online_No_Prescription_Needed_-_Buy_Zolpidem_Online_No_Prescription">152643</a> <a href="https://moravian.bucknell.edu/transcriptions/index.php?title=M_Amphetamine_Salts_Vs_ADDERALL_-_ADDERALL_10mg_15mg_20mg_25mg_30mg_40mg_Dosage">254881</a> <a href="http://aezian.co.kr/bbs/board.php?bo_table=free&wr_id=131044">290954</a> <a href="http://billvolhein.com/index.php/Cheap_Tramadol_100mg_Script_Without_Membership">Good Work!</a> <a href="https://sustainabilipedia.org/index.php/User:LouEads531198">271892</a> <a href="https://wp3.ebimarketing.com/apartment/buying-valium-over-the-internet-next-day-delivery.html">302133</a> <a href="https://bbarlock.com/index.php/User:LatoyaPartin">1071</a>
Anonymous on 02/01/2024 08:08
13 Publication year 223 687 1572 1 <a href=https://cialisa.buzz>cialis daily</a>
Anonymous on 14/04/2024 22:14
Hello! I could have sworn I've visited this website before but after looking at a
few of the articles I realized it's new to me.
Regardless, I'm certainly delighted I came across it and I'll
be bookmarking it and checking back frequently!
https://www.mannafood.co.kr/bbs/board.php?bo_table=free&wr_id=25702
?????? ?????? ? ??????
Anonymous on 20/04/2024 08:43
Pretty part of content. I simply stumbled upon your web site and in accession capital to assert that I acquire in fact loved account your blog posts.
Any way I will be subscribing for your augment and even I fulfillment you get entry to persistently rapidly.

http://thankyou.eoapps.co.kr/bbs/board.php?bo_table=free&wr_id=88376
????? ??? ??? ?????? ???
Anonymous on 15/05/2024 17:35
Ciao a tutti! Sono a Roma per il fine settimana, dove ci sono non solo un'abbondanza di monumenti storici come il Colosseo e il Vaticano, ma anche molteplici eventi. Ho visto annunci del casinò <a href=https://spinbetter.it/>Spin better</a>, mi chiedo se merita la pena visitarlo? Cerco anche consigli su posti insoliti, caffè locali o eventi, magari anche feste. Apprezzerei qualsiasi suggerimento!
Anonymous on 15/05/2024 19:14
Ciao a tutti! Sono a Roma per il fine settimana, dove ci sono non solo un'abbondanza di monumenti storici come il Colosseo e il Vaticano, ma anche numerosi eventi. Ho visto annunci del casinò <a href=https://spinbetter.it/>Spin better</a>, mi chiedo se convenga la pena fare una visita? Cerco anche consigli su posti insoliti, caffè locali o eventi, magari anche celebrazioni. Sarò riconoscente per qualsiasi suggerimento!

Login to comment Comment as anonymous