Waybar: Network module crashes waybar with bandwidthDownBits format specifier

Created on 10 Aug 2020  ยท  11Comments  ยท  Source: Alexays/Waybar

Hi!

Since the latest update (version 0.9.3), my network module crashes waybar on startup. More specifically, the bandwidthDownBits format does. Using the -l trace option gives no information on the error, I just get a segmentation fault.

Here is my network module configuration:

"network": {
        "format-ethernet": "๏œ€ {ifname} ({bandwidthDownBits})",
        "format-linked": "๏œ€ (No IP) โš ",
        "format-wifi": "๏‡ซ {essid} ({signalStrength}%)",
        "format-disconnected": "๏œ ๏ชฉ โš ",
    "on-click": "gnome-terminal -- nmtui",
    "on-click-right": "~/.config/rofi/scripts/network.sh",
        "tooltip": false
}

If I remove the {bandwidthDownBits} format, it works correctly. Note that all four formats that check the speed of the connection cause the crash.

Since I use Arch Linux with a recent 5.7.12 kernel, I thought it might be due to a change in the proc/net/netstat file, but it does not seem to be the case as far as I can tell.

bug

Most helpful comment

Many thanks to everyone, community/waybar 0.9.3-3 is now released and it includes this patch ๐Ÿ‘

All 11 comments

same behaviour with bandwidthUpBits too.

I confirm, this seem to happen since we upgraded fmt to v7. I just downgraded fmt to 6.2.1, recompiled and network module works as expected, no segfaults.

With fmt v7.0.3 this is a dump of a debug build:

       Message: Process 95054 (waybar) of user 1000 dumped core.

                Stack trace of thread 95054:
                #0  0x0000555ec303749a n/a (/home/maximbaz/Waybar/build/waybar + 0x4349a)
                #1  0x0000555ec303736d n/a (/home/maximbaz/Waybar/build/waybar + 0x4336d)
                #2  0x00007fcc72461e7a _ZN3fmt2v76detail23parse_replacement_fieldIcRNS1_14format_handlerINS1_13arg_formatterISt20back_insert_iteratorINS1_6bufferIcEEEcEEcNS0_20basic_format_contextIS8_cEEEEEEPKT_SG_SG_OT0_ (libfmt.so.7 + 0x17e7a)
                #3  0x00007fcc7246235d _ZN3fmt2v710vformat_toINS0_6detail13arg_formatterISt20back_insert_iteratorINS2_6bufferIcEEEcEEcNS0_20basic_format_contextIS7_cEEEENT1_8iteratorENT_8iteratorENS0_17basic_string_viewIT0_EENS0_17basic_format_argsISB_EENS2_10locale_refE (libfmt.so.7 + 0x1835d)
                #4  0x00007fcc724532a0 _ZN3fmt2v76detail7vformatB5cxx11ENS0_17basic_string_viewIcEENS0_11format_argsE (libfmt.so.7 + 0x92a0)
                #5  0x0000555ec30a4602 n/a (/home/maximbaz/Waybar/build/waybar + 0xb0602)
                #6  0x0000555ec304134b n/a (/home/maximbaz/Waybar/build/waybar + 0x4d34b)
                #7  0x0000555ec304211e n/a (/home/maximbaz/Waybar/build/waybar + 0x4e11e)
                #8  0x0000555ec3041fc7 n/a (/home/maximbaz/Waybar/build/waybar + 0x4dfc7)
                #9  0x00007fcc71bb741a _ZN4Glib16DispatchNotifier15pipe_io_handlerENS_11IOConditionE (libglibmm-2.4.so.1 + 0x4d41a)
                #10 0x00007fcc71bb427c _ZN4Glib8IOSource8dispatchEPN4sigc9slot_baseE (libglibmm-2.4.so.1 + 0x4a27c)
                #11 0x00007fcc71bb6b67 _ZN4Glib6Source14dispatch_vfuncEP8_GSourcePFiPvES3_ (libglibmm-2.4.so.1 + 0x4cb67)
                #12 0x00007fcc70fdf340 g_main_context_dispatch (libglib-2.0.so.0 + 0x52340)
                #13 0x00007fcc7102d1d9 n/a (libglib-2.0.so.0 + 0xa01d9)
                #14 0x00007fcc70fde221 g_main_context_iteration (libglib-2.0.so.0 + 0x51221)
                #15 0x00007fcc711dac9e g_application_run (libgio-2.0.so.0 + 0xcac9e)
                #16 0x0000555ec304bc8e n/a (/home/maximbaz/Waybar/build/waybar + 0x57c8e)
                #17 0x0000555ec303bfd3 n/a (/home/maximbaz/Waybar/build/waybar + 0x47fd3)
                #18 0x00007fcc70960002 __libc_start_main (libc.so.6 + 0x27002)
                #19 0x0000555ec30152ee n/a (/home/maximbaz/Waybar/build/waybar + 0x212ee)

@Alexays any quick ideas on how to fix this? ๐Ÿ™‚ I would imagine if fmt is used in other modules, those might need to be adjusted too, or at least tested.

Tried one by one, still reproduces even if I remove all these lines:

https://github.com/Alexays/Waybar/blob/f4d2ca27364134f22c366a5dfd0e47579006c63e/include/util/format.hpp#L76-L79

https://github.com/Alexays/Waybar/blob/master/include/util/format.hpp#L26
Adding a nullpointer check here stops it from crashing (I didn't take a deeper dive into the codebase):
if (it && (*it == '>' || *it == '<' || *it == '=')) {

@xenrox open a PR with the fix ๐Ÿ˜ƒ

@Alexays Well I am not sure how good the fix is, since I never looked at waybar's source before, but here it is.

Many thanks to everyone, community/waybar 0.9.3-3 is now released and it includes this patch ๐Ÿ‘

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilpianista picture ilpianista  ยท  4Comments

cryptoluks picture cryptoluks  ยท  4Comments

cmacrae picture cmacrae  ยท  4Comments

xajler picture xajler  ยท  5Comments

atomheartother picture atomheartother  ยท  3Comments