qtile / qtile

:cookie: A full-featured, hackable tiling window manager written and configured in Python (X11 + Wayland)
http://qtile.org
MIT License
4.81k stars 699 forks source link

Unexplained qtile crashes #2557

Closed piyushk closed 3 years ago

piyushk commented 3 years ago

Issue description

Unexplained qtile crashes drops me back to login. Happens 1-4 times a day.

Qtile version

version 0.17.0 (stable), 0.17.1.dev337+gb5fa83cc (master)

Stack traces

~/.xsession-errors

dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting XAUTHORITY=/home/piyushk/.Xauthority
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: setting CLUTTER_IM_MODULE=xim
dbus-update-activation-environment: setting GTIHOME=/home/piyushk/GTI
dbus-update-activation-environment: setting GTISOFT_LICENSE_FILE=27005@localhost
dbus-update-activation-environment: setting LANG=en_US.UTF-8
dbus-update-activation-environment: setting GDM_LANG=en_US
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting GTK2_MODULES=overlay-scrollbar
dbus-update-activation-environment: setting MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
dbus-update-activation-environment: setting XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/piyushk
dbus-update-activation-environment: setting USER=piyushk
dbus-update-activation-environment: setting DESKTOP_SESSION=ubuntu
dbus-update-activation-environment: setting QT4_IM_MODULE=xim
dbus-update-activation-environment: setting TEXTDOMAINDIR=/usr/share/locale/
dbus-update-activation-environment: setting DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
dbus-update-activation-environment: setting QT_QPA_PLATFORMTHEME=appmenu-qt5
dbus-update-activation-environment: setting PWD=/home/piyushk
dbus-update-activation-environment: setting HOME=/home/piyushk
dbus-update-activation-environment: setting TEXTDOMAIN=im-config
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: setting XDG_SESSION_TYPE=x11
dbus-update-activation-environment: setting XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/
dbus-update-activation-environment: setting XDG_SESSION_DESKTOP=ubuntu
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: setting SHELL=/bin/bash
dbus-update-activation-environment: setting XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
dbus-update-activation-environment: setting QT_IM_MODULE=ibus
dbus-update-activation-environment: setting XMODIFIERS=@im=ibus
dbus-update-activation-environment: setting IM_CONFIG_PHASE=2
dbus-update-activation-environment: setting XDG_CURRENT_DESKTOP=ubuntu:GNOME
dbus-update-activation-environment: setting GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
dbus-update-activation-environment: setting SHLVL=1
dbus-update-activation-environment: setting LANGUAGE=en_US
dbus-update-activation-environment: setting GDMSESSION=ubuntu
dbus-update-activation-environment: setting LOGNAME=piyushk
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting XDG_RUNTIME_DIR=/run/user/1000
dbus-update-activation-environment: setting XAUTHORITY=/home/piyushk/.Xauthority
dbus-update-activation-environment: setting XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
dbus-update-activation-environment: setting XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
dbus-update-activation-environment: setting PATH=/home/piyushk/bin:/home/piyushk/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/piyushk/GTI/bin
dbus-update-activation-environment: setting GTK_IM_MODULE=ibus
dbus-update-activation-environment: setting _=/usr/bin/dbus-update-activation-environment

~/.local/share/qtile/qtile.log

2021-06-17 11:26:38,507 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 491, in timer_setup
    update_interval = self.tick()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/clock.py", line 73, in tick
    self.update(self.poll())
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 462, in update
    old_width = self.layout.width
  File "/usr/local/lib/python3.8/dist-packages/libqtile/drawer.py", line 80, in width
    return self.layout.get_pixel_size()[0]
  File "/usr/local/lib/python3.8/dist-packages/libqtile/pangocffi.py", line 135, in get_pixel_size
    pango.pango_layout_get_pixel_size(self._pointer, width, height)
TypeError: initializer for ctype 'PangoLayout *' must be a cdata pointer, not NoneType
2021-06-17 11:26:38,514 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 491, in timer_setup
    update_interval = self.tick()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/clock.py", line 73, in tick
    self.update(self.poll())
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 468, in update
    self.draw()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 434, in draw
    self.drawer.draw(offsetx=self.offsetx, width=self.width)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/x11/drawer.py", line 159, in draw
    self.qtile.core.conn.conn.core.CopyArea(  # type: ignore
  File "/usr/lib/python3/dist-packages/xcffib/xproto.py", line 3035, in CopyArea
    return self.send_request(62, buf, is_checked=is_checked)
  File "/usr/lib/python3/dist-packages/xcffib/__init__.py", line 390, in send_request
    seq = self.conn.send_request(flags, xcb_parts + 2, xcb_req)
  File "/usr/lib/python3/dist-packages/xcffib/__init__.py", line 568, in wrapper
    self.invalid()
  File "/usr/lib/python3/dist-packages/xcffib/__init__.py", line 558, in invalid
    raise ConnectionException(err)
xcffib.ConnectionException: Unknown connection error.
2021-06-17 11:26:38,520 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 200, in update
    self.update_graph()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 254, in update_graph
    self.push(push_value)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 192, in push
    self.draw()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 150, in draw
    self.drawer.clear(self.background or self.bar.background)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 551, in clear
    self.set_source_rgb(colour)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 548, in set_source_rgb
    self.ctx.set_source_rgba(*utils.rgb(colour))
AttributeError: 'NoneType' object has no attribute 'set_source_rgba'
2021-06-17 11:26:38,523 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 200, in update
    self.update_graph()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 289, in update_graph
    self.push(
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 192, in push
    self.draw()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 150, in draw
    self.drawer.clear(self.background or self.bar.background)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 551, in clear
    self.set_source_rgb(colour)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 548, in set_source_rgb
    self.ctx.set_source_rgba(*utils.rgb(colour))
AttributeError: 'NoneType' object has no attribute 'set_source_rgba'
2021-06-17 11:26:38,524 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/quick_exit.py", line 61, in update
    self.text = self.countdown_format.format(self.countdown)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 355, in text
    self.layout.text = self.formatted_text
  File "/usr/local/lib/python3.8/dist-packages/libqtile/drawer.py", line 72, in text
    self.layout.set_attributes(attrlist)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/pangocffi.py", line 115, in set_attributes
    pango.pango_layout_set_attributes(self._pointer, attrs)
TypeError: initializer for ctype 'PangoLayout *' must be a cdata pointer, not NoneType
2021-06-17 11:26:38,533 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate

Configuration

# Copyright (c) 2010 Aldo Cortesi
# Copyright (c) 2010, 2014 dequis
# Copyright (c) 2012 Randall Ma
# Copyright (c) 2012-2014 Tycho Andersen
# Copyright (c) 2012 Craig Barnes
# Copyright (c) 2013 horsik
# Copyright (c) 2013 Tao Sauvage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# import os
# import subprocess
from typing import List  # noqa: F401

from libqtile import bar, layout, widget
# from libqtile import hook
from libqtile.config import Click, Drag, Group, Key, Match, Screen
from libqtile.lazy import lazy
# from libqtile.log_utils import logger

mod = "mod4"

keys = [
    # Switch between windows
    Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
    Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
    Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
    Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
    Key([mod], "space", lazy.layout.next(),
        desc="Move window focus to other window"),

    # Move windows between left/right columns or move up/down in current stack.
    # Moving out of range in Columns layout will create new column.
    Key([mod, "shift"], "h", lazy.layout.shuffle_left(),
        desc="Move window to the left"),
    Key([mod, "shift"], "l", lazy.layout.shuffle_right(),
        desc="Move window to the right"),
    Key([mod, "shift"], "j", lazy.layout.shuffle_down(),
        desc="Move window down"),
    Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),

    # Grow windows. If current window is on the edge of screen and direction
    # will be to screen edge - window would shrink.
    Key([mod, "control"], "h", lazy.layout.grow_left(),
        desc="Grow window to the left"),
    Key([mod, "control"], "l", lazy.layout.grow_right(),
        desc="Grow window to the right"),
    Key([mod, "control"], "j", lazy.layout.grow_down(),
        desc="Grow window down"),
    Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"),
    Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),

    # Toggle between different layouts as defined below
    Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
    Key([mod], "w", lazy.window.kill(), desc="Kill focused window"),

    Key([mod, "control"], "r", lazy.restart(), desc="Restart Qtile"),
    Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"),

    # Custom qtile stuff
    Key([mod], "p", lazy.spawn("dmenu_run")),
    Key([mod, "shift"], "Return", lazy.spawn("gnome-terminal --hide-menubar"), desc="Launch terminal"),
    Key([mod, "shift"], "c", lazy.window.kill(), desc="Kill focused window"),
    Key([mod], "t", lazy.window.toggle_floating()),
]

groups = [Group(i) for i in "123456789"]

for i in groups:
    keys.extend([
        # mod1 + letter of group = switch to group
        Key([mod], i.name, lazy.group[i.name].toscreen(),
            desc="Switch to group {}".format(i.name)),

        # mod1 + shift + letter of group = switch to & move focused window to group
        Key([mod, "shift"], i.name, lazy.window.togroup(i.name, switch_group=False),
            desc="Switch to & move focused window to group {}".format(i.name)),
        # Or, use below if you prefer not to switch to that group.
        # # mod1 + shift + letter of group = move focused window to group
        # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
        #     desc="move focused window to group {}".format(i.name)),
    ])

layouts = [
    # layout.Columns(border_focus_stack='#d75f5f'),
    # layout.Max(),
    # Try more layouts by unleashing below layouts.
    # layout.Stack(num_stacks=2),
    # layout.Bsp(),
    # layout.Matrix(),
    layout.MonadTall(border_width=2),
    # layout.MonadWide(),
    # layout.RatioTile(),
    # layout.Tile(),
    # layout.TreeTab(),
    # layout.VerticalTile(),
    # layout.Zoomy(),
]

widget_defaults = dict(
    font='sans',
    fontsize=12,
    padding=3,
)
extension_defaults = widget_defaults.copy()

screens = [
    Screen(
        wallpaper='/usr/share/backgrounds/Black_hole_by_Marek_Koteluk.jpg',
        wallpaper_mode='fill',
        top=bar.Bar(
            [
                widget.GroupBox(),
                widget.Sep(),
                widget.CurrentLayout(),
                widget.Sep(),
                widget.WindowName(),
                widget.Sep(),
                widget.Systray(),
                widget.TextBox(text='CPU:',fontsize=12),
                widget.Volume(device='pulse'),
                widget.CPUGraph(border_color='8b4500', fill_color='cd6600', graph_color='ee7600'), #family of dark orange colors
                widget.TextBox(text='Mem:',fontsize=12),
                widget.MemoryGraph(),
                widget.Clock(format='%B %d, %Y - %A %I:%M:%S %p', fontsize=12),
                widget.QuickExit(),
            ],
            24,
        ),
    ),
    Screen(
        wallpaper='/usr/share/backgrounds/160218-deux-two_by_Pierre_Cante.jpg',
        wallpaper_mode='fill',
         top=bar.Bar(
             [
                 widget.GroupBox(),
                 widget.Sep(),
                 widget.CurrentLayout(),
                 widget.Sep(),
                 widget.WindowName(),
                 widget.Sep(),
                 widget.Clock(format='%B %d, %Y - %A %I:%M:%S %p', fontsize=12),
                 widget.QuickExit(),
             ],
            24,
        ),
    )
]

# Drag floating layouts.
mouse = [
    Drag([mod], "Button1", lazy.window.set_position_floating(),
         start=lazy.window.get_position()),
    Drag([mod], "Button3", lazy.window.set_size_floating(),
         start=lazy.window.get_size()),
    Click([mod], "Button2", lazy.window.bring_to_front())
]

dgroups_key_binder = None
dgroups_app_rules = []  # type: List
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
floating_layout = layout.Floating(float_rules=[
    # Run the utility of `xprop` to see the wm class and name of an X client.
    *layout.Floating.default_float_rules,
    Match(wm_class='confirmreset'),  # gitk
    Match(wm_class='makebranch'),  # gitk
    Match(wm_class='maketag'),  # gitk
    Match(wm_class='ssh-askpass'),  # ssh-askpass
    Match(title='branchdialog'),  # gitk
    Match(title='pinentry'),  # GPG key password entry
])
auto_fullscreen = True
focus_on_window_activation = "smart"
reconfigure_screens = True

# If things like steam games want to auto-minimize themselves when losing
# focus, should we respect this or not?
auto_minimize = True

# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
# mailing lists, GitHub issues, and other WM documentation that suggest setting
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
# java that happens to be on java's whitelist.
wmname = "LG3D"

# @hook.subscribe.startup
# def autostart():
#     output = subprocess.check_output(
#         os.path.expanduser('~/.config/qtile/autostart.sh'),
#         shell=True
#     ).decode('utf-8')
#     logger.error(output)
piyushk commented 3 years ago

A crash later in the day had a single log line in qtile.log:

2021-06-17 19:23:41,805 ERROR libqtile base.py:_wrapper():L304 got exception from widget timer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/base.py", line 302, in _wrapper
    method(*method_args)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 200, in update
    self.update_graph()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 289, in update_graph
    self.push(
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 192, in push
    self.draw()
  File "/usr/local/lib/python3.8/dist-packages/libqtile/widget/graph.py", line 150, in draw
    self.drawer.clear(self.background or self.bar.background)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 551, in clear
    self.set_source_rgb(colour)
  File "/usr/local/lib/python3.8/dist-packages/libqtile/backend/base.py", line 548, in set_source_rgb
    self.ctx.set_source_rgba(*utils.rgb(colour))
AttributeError: 'NoneType' object has no attribute 'set_source_rgba'
2021-06-17 19:23:41,808 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate
m-col commented 3 years ago

Looks awfully similar to https://github.com/qtile/qtile/issues/2307

m-col commented 3 years ago

In addition to #2307 both of the log outputs you've posted appeared in https://github.com/qtile/qtile/issues/2509. The direct cause of all of these is the same: the classes are finalized but then shortly after do something using finalized attributes. #2509 refers to clean-up when shutting Qtile down, and #2307 mentions that the error and freeze happens when restarting. Do you find any pattern with when these errors happen, such as when restarting?

piyushk commented 3 years ago

@m-col I experienced these errors during regular operation. The screen freezes and I get dropped down to the login screen -- it's pretty terrible.

They might be happening during restarts. I'll check and report back by Monday.

piyushk commented 3 years ago

Does not happen on restarts. If I use the restart shortcut, qtile restarts as expected and I see only 1 log line in qtile.log:

2021-06-20 16:55:36,986 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
piyushk commented 3 years ago

@m-col I've switched to your PR branch to see if it goes away in the hopes that this issue will go away. Lately, I've confirmed that qtile is now arbitrarily restarting with nothing barring the following in the qtile log:

2021-06-28 15:47:26,756 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate

I'll report back if your PR fixes the issue. I can't seem to roll back to an old version of qtile since I can no longer log in if I switch to them.

piyushk commented 3 years ago

I've confirmed that the PR branch from #2360 does not solve this issue. I still experience sporadic crashes.

m-col commented 3 years ago

Does this still happen, and if so perhaps try on master? In the past few months we have fixed a few bugs, and ironed out that PR which is now merged too (with its own bugs fixed).

Failing that, try getting the debug log output. You can enable that with qtile cmd-obj -o cmd -f debug.

piyushk commented 3 years ago

I've switched my WM from qtile and won't be able to test this issue. It's great to hear that some bug fixes are in. Perhaps this specific issue can be closed?

m-col commented 3 years ago

Great, thanks for the update.