Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Segmentation fault when restarting/reloading polybar #3111

Open
5 tasks done
unode opened this issue Apr 12, 2024 · 3 comments
Open
5 tasks done

[Bug]: Segmentation fault when restarting/reloading polybar #3111

unode opened this issue Apr 12, 2024 · 3 comments

Comments

@unode
Copy link

unode commented Apr 12, 2024

Checklist

  • I have read the appropriate section in the contributing guidelines
  • I believe this issue is a problem with polybar itself and not a misconfiguration on my part
  • I have searched for other open and closed issues that may have already reported this problem
  • I have checked the known issues page for this problem.
  • I have followed the debugging guide to narrow down the problem to a minimal config.

Steps to reproduce

Run kill -9 $(pgrep polybar) ; polybar -c ~/.config/polybar/test.cfg -r main & a few times in a row.

I believe the issue is related with the new tray module.
I only started experiencing these crashes after switching from the old tray system due to the deprecation warnings.

Minimal config

[bar/main]
;monitor = ${env:MONITOR:HDMI1}
width = 100%
height = 20
;offset-x = 1%
;offset-y = 1%
radius = 1.0
fixed-center = false

background = ${colors.background}
foreground = ${colors.foreground}

line-size = 1
line-color = #fff

border-size = 2
border-color = #00000000

padding-left = 0
padding-right = 1

module-margin-left = 1
module-margin-right = 1

font-0 = fixed:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1
font-3 = Noto Emoji:scale=15:antialias=false;0

modules-left = i3
modules-right = tray

cursor-click = pointer
cursor-scroll = ns-resize

[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false

label-mode-padding = 2
label-mode-foreground = ${colors.foreground}
label-mode-background = ${colors.primary}

label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline = ${colors.blue}
label-focused-padding = 1

label-unfocused = %index%
label-unfocused-padding = 1

label-visible = %index%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}

label-urgent = %index%
label-urgent-background = ${colors.alert}
label-urgent-padding = 1

[module/tray]
type = internal/tray
tray-padding = 1

[global/wm]
margin-top = 5
margin-bottom = 5

Polybar log

otice: Loading module 'tray' of type 'internal/tray'
notice: Loaded 2 modules
notice: Loaded font "fixed:pixelsize=10" (name=Fixed, offset=1, file=/nix/store/2n3gp57bb21vq93ca0817b5g2ip5n2fy-font-misc-misc-1.1.3/lib/X11/fonts/misc/6x10-ISO8859-1.pcf.gz)
error: tray: Failed to unembed window '' (0x2e00890)
error: tray: Failed to setup tray client '' (0x2e00890) removing... (XCB_WINDOW (3))
error: tray: Failed to unembed window '' (0x127573f)
error: tray: Failed to setup tray client '' (0x127573f) removing... (XCB_WINDOW (3))
error: tray: Failed to unembed window '' (0x0600a4b)

# Stack trace and error log collected by systemd:

Apr 12 14:50:03 magnetar xsession[128875]: error 140: BadRegion request 138 minor 14 serial 9845787
Apr 12 14:50:03 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 15 minor 0 serial 9852286
Apr 12 14:50:12 magnetar xsession[128875]: error 140: BadRegion request 138 minor 14 serial 9907108
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 15 minor 0 serial 9912069
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 20 minor 0 serial 9912455
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 15 minor 0 serial 9912456
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 20 minor 0 serial 9913212
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 15 minor 0 serial 9913213
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 20 minor 0 serial 9914695
Apr 12 14:50:12 magnetar xsession[128875]: error 3: BadWindow (invalid Window parameter) request 15 minor 0 serial 9914696
Apr 12 14:50:13 magnetar systemd-coredump[142819]: [🡕] Process 142767 (polybar) of user 1000 dumped core.
                                                   Module libcap.so.2 without build-id.
                                                   Module libmp3lame.so.0 without build-id.
                                                   Module libmpg123.so.0 without build-id.
                                                   Module libogg.so.0 without build-id.
                                                   Module libopus.so.0 without build-id.
                                                   Module libvorbisenc.so.2 without build-id.
                                                   Module libvorbis.so.0 without build-id.
                                                   Module libFLAC.so.12 without build-id.
                                                   Module libsystemd.so.0 without build-id.
                                                   Module libsndfile.so.1 without build-id.
                                                   Module libkeyutils.so.1 without build-id.
                                                   Module libkrb5support.so.0 without build-id.
                                                   Module libcom_err.so.3 without build-id.
                                                   Module libk5crypto.so.3 without build-id.
                                                   Module libkrb5.so.3 without build-id.
                                                   Module libunistring.so.5 without build-id.
                                                   Module libbrotlicommon.so.1 without build-id.
                                                   Module libxcb-render-util.so.0 without build-id.
                                                   Module libdbus-1.so.3 without build-id.
                                                   Module libpulsecommon-16.1.so without build-id.
                                                   Module libzstd.so.1 without build-id.
                                                   Module libgssapi_krb5.so.2 without build-id.
                                                   Module libssh2.so.1 without build-id.
                                                   Module libidn2.so.0 without build-id.
                                                   Module libnghttp2.so.14 without build-id.
                                                   Module libXdmcp.so.6 without build-id.
                                                   Module libXau.so.6 without build-id.
                                                   Module libexpat.so.1 without build-id.
                                                   Module libbrotlidec.so.1 without build-id.
                                                   Module libbz2.so.1 without build-id.
                                                   Module libxcb-shm.so.0 without build-id.
                                                   Module libxcb-render.so.0 without build-id.
                                                   Module libXrender.so.1 without build-id.
                                                   Module libXext.so.6 without build-id.
                                                   Module libX11.so.6 without build-id.
                                                   Module libpng16.so.16 without build-id.
                                                   Module libz.so.1 without build-id.
                                                   Module libgcc_s.so.1 without build-id.
                                                   Module libstdc++.so.6 without build-id.
                                                   Module libxcb-xrm.so.0 without build-id.
                                                   Module libxcb-cursor.so.0 without build-id.
                                                   Module libpulse.so.0 without build-id.
                                                   Module libnl-3.so.200 without build-id.
                                                   Module libnl-genl-3.so.200 without build-id.
                                                   Module libmpdclient.so.2 without build-id.
                                                   Module libasound.so.2 without build-id.
                                                   Module libjsoncpp.so.25 without build-id.
                                                   Module libxcb-xkb.so.1 without build-id.
                                                   Module libxcb-composite.so.0 without build-id.
                                                   Module libxcb-randr.so.0 without build-id.
                                                   Module libxcb-image.so.0 without build-id.
                                                   Module libxcb-util.so.1 without build-id.
                                                   Module libxcb-icccm.so.4 without build-id.
                                                   Module libxcb-ewmh.so.2 without build-id.
                                                   Module libxcb.so.1 without build-id.
                                                   Module libfreetype.so.6 without build-id.
                                                   Module libfontconfig.so.1 without build-id.
                                                   Module polybar without build-id.
                                                   Stack trace of thread 142767:
                                                   #0  0x00000000006260e0 _ZNK7polybar4tray6client6mappedEv (polybar + 0x2260e0)
                                                   #1  0x000000000054c8d0 _ZNK7polybar4tray7manager11calculate_wEv (polybar + 0x14c8d0)
                                                   #2  0x000000000054d0b9 _ZN7polybar4tray7manager17recalculate_widthEv (polybar + 0x14d0b9)
                                                   #3  0x000000000054d9b8 _ZN7polybar4tray7manager11reconfigureEv (polybar + 0x14d9b8)
                                                   #4  0x00000000005330d7 _ZNK3xpp1x5event10dispatcherIRN7polybar10connectionEEclINS_5event8registryIS5_JNS_5randr9extensionENS_9composite9extensionENS_3xkb9extensionEEE7handlerEEEbT_RKSt10shared_ptrI19xcb_generic_event_tE.isra.0 (polybar + 0x1330d7)
                                                   #5  0x0000000000534a29 _ZNK7polybar10connection14dispatch_eventERKSt10shared_ptrI19xcb_generic_event_tE (polybar + 0x134a29)
                                                   #6  0x000000000048b0d0 _ZN7polybar10controller7conn_cbEv (polybar + 0x8b0d0)
                                                   #7  0x00000000004a5439 _ZN7polybar9eventloop10PollHandle13poll_callbackEP9uv_poll_sii (polybar + 0xa5439)
                                                   #8  0x00007f95f524f2ea uv__io_poll (libuv.so.1 + 0x242ea)
                                                   #9  0x00007f95f523c8d0 uv_run (libuv.so.1 + 0x118d0)
                                                   #10 0x00000000004a66be _ZN7polybar9eventloop4loop3runEv (polybar + 0xa66be)
                                                   #11 0x000000000048d55f _ZN7polybar10controller11read_eventsEb (polybar + 0x8d55f)
                                                   #12 0x000000000048e994 _ZN7polybar10controller3runEbNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb (polybar + 0x8e994)
                                                   #13 0x000000000044c40c main (polybar + 0x4c40c)
                                                   #14 0x00007f95f4a3efce __libc_start_call_main (libc.so.6 + 0x27fce)
                                                   #15 0x00007f95f4a3f089 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x28089)
                                                   #16 0x000000000044f915 _start (polybar + 0x4f915)

                                                   Stack trace of thread 142776:
                                                   #0  0x0000000000000000 n/a (n/a + 0x0)
                                                   ELF object binary architecture: AMD x86-64

Expected behavior

No segmentation fault

Actual behavior

Segmentation fault. Especially when replacing an existing polybar instance screenchange-reload = true

Window Manager and Version

i3 version 4.23

Linux Distribution

NixOS 23.11

Polybar version

polybar 3.7.0

Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard

X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor

Build type: Release
Compiler: /nix/store/ihhhd1r1a2wb4ndm24rnm83rfnjw5n0z-gcc-wrapper-12.3.0/bin/g++
Compiler flags:  -O3 -DNDEBUG -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override
Linker flags:  -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override  -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override

Additional Context / Screenshots

No response

@patrick96
Copy link
Member

I can't reproduce this myself unfortunately. Which applications were running in your tray at the time? This behavior probably depends on how those applications interact with polybar.

Looking at the code, I found one issue that may cause this. I have fixed that in #3112, feel free to try it out and see if it fixes things.

@unode
Copy link
Author

unode commented Apr 14, 2024

Tried the patch and repeated the steps and couldn't replicate the segfault.
From this quick test it looks like the patch fixes the issue. Thanks!

patrick96 added a commit to patrick96/polybar that referenced this issue Apr 15, 2024
The vector::erase call needs to be supplied with the end of the range,
otherwise only a single element is removed.

Fixes polybar#3111
@patrick96
Copy link
Member

Nice, thanks for testing. Glad this was an easy fix, tray stuff usually is anything but

@patrick96 patrick96 added this to the 3.7.2 milestone Apr 15, 2024
patrick96 added a commit that referenced this issue Apr 15, 2024
The vector::erase call needs to be supplied with the end of the range,
otherwise only a single element is removed.

Fixes #3111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants