Skip to content

segfault when building the xworkspace-nodes from desktop-labels #1444

@kronn

Description

@kronn

I sometimes run into a segfault during my work on #882 .

Expected behavior:

I expect no segfault :-)

Actual behavior:

When running the bar under gdb until the segfault, I get the following backtrace:

#0  std::__shared_ptr<polybar::v3_2_0_52_g1550152_git::drawtypes::label, (__gnu_cxx::_Lock_policy)2>::get (this=0x10)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/shared_ptr_base.h:1060
#1  <function called from gdb>
#2  std::__shared_ptr<polybar::v3_2_0_52_g1550152_git::drawtypes::label, (__gnu_cxx::_Lock_policy)2>::get (this=0x10)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/shared_ptr_base.h:1060
Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
#3  0x00000000009114a7 in polybar::v3_2_0_52_g1550152_git::modules::xworkspaces_module::build (this=0xcf5760, builder=0xcf5bf0, tag=)
    at /home/mviehweger/Code/opensource/polybar/src/modules/xworkspaces.cpp:310
#4  0x000000000091a1f5 in polybar::v3_2_0_52_g1550152_git::modules::module<polybar::v3_2_0_52_g1550152_git::modules::xworkspaces_module>::get_output[abi:cxx11]() (this=0xcf5760) at /home/mviehweger/Code/opensource/polybar/include/modules/meta/base.inl:160
#5  0x0000000000910e95 in polybar::v3_2_0_52_g1550152_git::modules::xworkspaces_module::get_output[abi:cxx11]() (this=0xcf5760)
    at /home/mviehweger/Code/opensource/polybar/src/modules/xworkspaces.cpp:280
#6  0x0000000000919a0d in polybar::v3_2_0_52_g1550152_git::modules::module<polybar::v3_2_0_52_g1550152_git::modules::xworkspaces_module>::contents[abi:cxx11]() (this=0xcf5760) at /home/mviehweger/Code/opensource/polybar/include/modules/meta/base.inl:82
#7  0x00000000007bf711 in polybar::v3_2_0_52_g1550152_git::controller::process_update (this=0xcf4b70, force=false)
    at /home/mviehweger/Code/opensource/polybar/src/components/controller.cpp:481
#8  0x00000000007bd22b in polybar::v3_2_0_52_g1550152_git::controller::process_eventqueue (this=0xcf4b70)
    at /home/mviehweger/Code/opensource/polybar/src/components/controller.cpp:394
#9  0x00000000007d36c9 in std::_Mem_fn_base<void (polybar::v3_2_0_52_g1550152_git::controller::*)(), true>::operator()<, void>(polybar::v3_2_0_52_g1550152_git::controller*) const (this=0xd30ca0, __object=0xcf4b70) at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/functional:600
#10 0x00000000007d3632 in std::_Bind_simple<std::_Mem_fn<void (polybar::v3_2_0_52_g1550152_git::controller::*)()> (polybar::v3_2_0_52_g1550152_git::controller*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0xd30c98) at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/functional:1530
#11 0x00000000007d35e5 in std::_Bind_simple<std::_Mem_fn<void (polybar::v3_2_0_52_g1550152_git::controller::*)()> (polybar::v3_2_0_52_g1550152_git::controller*)>::operator()() (this=0xd30c98) at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/functional:1520
#12 0x00000000007d33a9 in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (polybar::v3_2_0_52_g1550152_git::controller::*)()> (polybar::v3_2_0_52_g1550152_git::controller*)> >::_M_run() (this=0xd30c80) at /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/thread:115
#13 0x00007ffff54b5c80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#14 0x00007ffff4cc86ba in start_thread (arg=0x7fffe17fa700) at pthread_create.c:333
#15 0x00007ffff49fe41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Environment:

  • WM: xmonad
  • Output of polybar -vvv:

polybar 3.2.0-52-g1550152-git

Features: +alsa +curl -i3 +mpd +network(wireless-tools) +pulseaudio +xkeyboard

X extensions: +randr (-monitors) -render -damage -sync -composite +xkb +xrm -xcursor

Build type: Debug
Compiler: /usr/bin/clang++
Compiler flags: -Wall -Wextra -Werror -O2 -pedantic -pedantic-errors -Wno-error=parentheses-equality -Wno-zero-length-array
Linker flags:

The master of polybar that I am building on top of is 2fba443.

Attempted debugging

PR #882 does not change the source-code from which the segfault originates, but it shifts its location a few lines down. See https://github.com/jaagr/polybar/pull/882/files#diff-e89fe726ad41f4ae273dacfca026a7ddR310 for the code mentioned here.

From the above backtrace, I poked around a little to know more. In order to establish the context in which this on segfaults, I did the following:

(gdb) f 3
Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
#3  0x00000000009114a7 in polybar::v3_2_0_52_g1550152_git::modules::xworkspaces_module::build (this=0xcf5760, builder=0xcf5bf0, tag=)
    at /home/mviehweger/Code/opensource/polybar/src/modules/xworkspaces.cpp:310
310	        if (desktop->label.get()) {
(gdb) p m_index 
$2 = 0
(gdb) p m_viewports 
$3 = std::vector of length 1, capacity 1 = {std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::viewport> containing 0xcef500}
(gdb) p m_viewports[0]->desktops 
$4 = std::vector of length 9, capacity 16 = {std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd69690, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd03380, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd41e50, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd37830, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd3ac80, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd03a30, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd3ad70, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd38460, 
  std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0xd4b2b0}
(gdb) p desktop
$5 = std::unique_ptr<polybar::v3_2_0_52_g1550152_git::modules::desktop> containing 0x0

Related Problems

This time, the segfault originates from desktop->label.get(), other times, it manages to get a few lines further until desktop->label is called/passed to the builder.

I assume by now, that xmonad changes the desktop-properties and that this somehow invalidates/corrupts the data-structure. My proposed solution is to add another check against invalid desktop-pointers.

Keep in mind, I have little knowledge about X11-properties, C++(-datastructures) and the interaction between the moving parts here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions