Skip to content

Python 3.11.4 on Debian: ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648 #7735

Closed

Description

@4nd3r

Using master branch on Debian Sid with qt6.

Python 3.11.4-1 packages landed (in unstable) and broke qutebrowser.

Same with 3.11.3-2 (was in experimental only).

3.11.2-6 is good.

Traceback (most recent call last):
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/eventfilter.py", line 104, in eventFilter
    return handler(cast(QKeyEvent, event))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/eventfilter.py", line 74, in _handle_key_event
    return man.handle_event(event)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/modeman.py", line 471, in handle_event
    return handler(cast(QKeyEvent, event))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/modeman.py", line 292, in _handle_keypress
    match = parser.handle(event, dry_run=dry_run)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/modeparsers.py", line 115, in handle
    match = super().handle(e, dry_run=dry_run)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/basekeyparser.py", line 295, in handle
    self._debug_log(f"Got key: {info!r} (dry_run {dry_run})")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/keyutils.py", line 371, in __repr__
    text=str(self),
         ^^^^^^^^^
  File "/home/ander/Desktop/qutebrowser/qutebrowser/keyinput/keyutils.py", line 422, in __str__
    modifiers &= ~_MODIFIER_MAP[self.key]  # type: ignore[assignment]
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1542, in __invert__
    self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 711, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1136, in __new__
    raise exc
  File "/usr/lib/python3.11/enum.py", line 1113, in __new__
    result = cls._missing_(value)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1454, in _missing_
    raise ValueError('%r: no members with value %r' % (cls, unknown))
ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648
Fatal Python error: Segmentation fault

Current thread 0x00007f66d9330040 (most recent call first):
  File "/home/ander/Desktop/qutebrowser/qutebrowser/app.py", line 140 in qt_mainloop
  File "/home/ander/Desktop/qutebrowser/qutebrowser/app.py", line 130 in run
  File "/home/ander/Desktop/qutebrowser/qutebrowser/qutebrowser.py", line 245 in main
  File "/home/ander/Desktop/qutebrowser/.venv/bin/qutebrowser", line 33 in <module>

Extension modules: PyQt6.QtCore, PyQt6.QtGui, PyQt6.QtWidgets, markupsafe._speedups, yaml._yaml, PyQt6.QtNetwork, PyQt6.QtQml, PyQt6.QtOpenGL, PyQt6.QtDBus, PyQt6.QtWebChannel, PyQt6.QtWebEngineCore, PyQt6.QtPrintSupport, PyQt6.QtWebEngineWidgets, PyQt6.QtSql (total: 14)
Segmentation fault

Activity

  1. changed the title [-]Python 3.11.4 segmentation fault[/-] [+]Python 3.11.3 and 3.11.4 segmentation fault[/+] on Jun 8, 2023
  2. The-Compiler commented on Jun 8, 2023

    @The-Compiler
    Member

    Works fine here on Archlinux with 3.11.3.

    Confusingly, I can see in Debian's Package Tracker that the versions you mention indeed exist, but the git link there has its latest change a month ago...

    Given this has worked fine for everyone outside of Debian so far, and their rather large amount of patches on top of Python, I wonder if those break something?

    In any case, the actual issue is probably ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648 and not the segfault. That value is 0x80000000.

    Can you please show your full --version information (assuming that should still work fine), as well as the output you get before the exception with --debug?

  3. changed the title [-]Python 3.11.3 and 3.11.4 segmentation fault[/-] [+]Python 3.11.3/.4 on Debian: ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648[/+] on Jun 8, 2023
  4. added
    component: keyinputIssues related to processing keypresses.
    status: needs triageIssues/PRs which need some deeper investigation.
    bug: exceptionA Python exception gets thrown.
    qt: 6Issues related to Qt 6.
    priority: 0 - highIssues which are currently the primary focus.
    and removed
    status: needs triageIssues/PRs which need some deeper investigation.
    on Jun 8, 2023
  5. changed the title [-]Python 3.11.3/.4 on Debian: ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648[/-] [+]Python 3.11.4 on Debian: ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648[/+] on Jun 8, 2023
  6. The-Compiler commented on Jun 8, 2023

    @The-Compiler
    Member

    Reproduced with Python 3.11.4. I'm assuming the 3.11.3 thing was a red herring (maybe you had an existing instance still open?).

    Logs:

    13:28:25 DEBUG    keyboard   basekeyparser:_debug_log:216 NormalKeyParser for mode normal: Got key: <qutebrowser.keyinput.keyutils.KeyInfo key='Key_O' modifiers='NoModifier' text='o'> (dry_run True)
    13:28:25 ERROR    misc       crashsignal:_handle_early_exits:241 Uncaught exception
    Traceback (most recent call last):
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/eventfilter.py", line 114, in eventFilter
        return handler(cast(QKeyEvent, event))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/eventfilter.py", line 75, in _handle_key_event
        return man.handle_event(event)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/modeman.py", line 471, in handle_event
        return handler(cast(QKeyEvent, event))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/modeman.py", line 292, in _handle_keypress
        match = parser.handle(event, dry_run=dry_run)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/modeparsers.py", line 115, in handle
        match = super().handle(e, dry_run=dry_run)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/basekeyparser.py", line 302, in handle
        sequence = self._sequence.append_event(e)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/florian/proj/qutebrowser/git/qutebrowser/keyinput/keyutils.py", line 672, in append_event
        modifiers &= ~Qt.KeyboardModifier.GroupSwitchModifier
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 1542, in __invert__
        self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 711, in __call__
        return cls.__new__(cls, value)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 1136, in __new__
        raise exc
      File "/usr/lib/python3.11/enum.py", line 1113, in __new__
        result = cls._missing_(value)
                 ^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 1454, in _missing_
        raise ValueError('%r: no members with value %r' % (cls, unknown))
    ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648

    Assuming it's this change: python/cpython#103365

    This seems... like pretty bad for a patch release!

  7. 4nd3r commented on Jun 8, 2023

    @4nd3r
    ContributorAuthor

    I'm assuming the 3.11.3 thing was a red herring (maybe you had an existing instance still open?)

    Nope.

    Downloaded related packages from snapshot.debian.org:

    ander@m720q:~$ l Downloads/python_3.11.*
    Downloads/python_3.11.2-6:
    libpython3.11-dev_3.11.2-6_amd64.deb
    libpython3.11-minimal_3.11.2-6_amd64.deb
    libpython3.11-stdlib_3.11.2-6_amd64.deb
    libpython3.11_3.11.2-6_amd64.deb
    python3.11-dev_3.11.2-6_amd64.deb
    python3.11-minimal_3.11.2-6_amd64.deb
    python3.11-venv_3.11.2-6_amd64.deb
    python3.11_3.11.2-6_amd64.deb
    
    Downloads/python_3.11.3-2:
    libpython3.11-dev_3.11.3-2_amd64.deb
    libpython3.11-minimal_3.11.3-2_amd64.deb
    libpython3.11-stdlib_3.11.3-2_amd64.deb
    libpython3.11_3.11.3-2_amd64.deb
    python3.11-dev_3.11.3-2_amd64.deb
    python3.11-minimal_3.11.3-2_amd64.deb
    python3.11-venv_3.11.3-2_amd64.deb
    python3.11_3.11.3-2_amd64.deb
    

    Same problem with .4 (currently in repo) and .3 (from snapshot).

    Can you please show your full --version information (assuming that should still work fine), as well as the output you get before the exception with --debug?

    Nothing special there. For example:

    15:27:26 DEBUG    init       earlyinit:init_log:294 Log initialized.
    15:27:27 DEBUG    init       app:run:85 Main process PID: 70197
    15:27:27 DEBUG    init       app:run:87 Initializing directories...
    15:27:27 DEBUG    init       standarddir:init:356 Base directory: /tmp/qutebrowser-basedir-fu41wzsl
    15:27:27 DEBUG    init       app:run:91 Initializing config...
    15:27:27 DEBUG    init       app:run:94 Initializing application...
    15:27:27 DEBUG    init       darkmode:settings:362 Darkmode variant: qt_63
    15:27:27 DEBUG    init       app:__init__:553 Commandline args: ['-T', '--version', '--debug']
    15:27:27 DEBUG    init       app:__init__:554 Parsed: Namespace(basedir='/tmp/qutebrowser-basedir-fu41wzsl', config_py=None, version=True, temp_settings=[], session=None, override_restore=False, backend=None, desktop_file_name='org.qutebrowser.qutebrowser', untrusted_args=False, json_args=None, temp_basedir_restarted=False, enable_webengine_inspector=False, loglevel=None, logfilter=None, loglines=2000, debug=True, json_logging=False, color=True, force_color=False, nowindow=False, temp_basedir=True, no_err_windows=False, qt_arg=None, qt_flag=None, debug_flags=[], command=[], url=[])
    15:27:27 DEBUG    init       app:__init__:555 Qt arguments: ['--webEngineArgs', '--enable-features=WebRTCPipeWireCapturer,OverlayScrollbar']
    15:27:27 DEBUG    init       app:__init__:560 Initializing application...
    15:27:27 DEBUG    sql        sql:run:375 pragma user_version
    15:27:27 DEBUG    sql        sql:run:375 PRAGMA journal_mode=WAL
    15:27:27 DEBUG    sql        sql:run:375 PRAGMA synchronous=NORMAL
    15:27:27 DEBUG    sql        sql:run:375 select sqlite_version()
             ______     ,,
        ,.-"`      | ,-` |
      .^           ||    |
     /    ,-*^|    ||    |
    ;    /    |    ||    ;-*```^*.
    ;   ;     |    |;,-*`         \
    |   |     |  ,-*`    ,-"""\    \
    |    \   ,-"`    ,-^`|     \    |
     \    `^^    ,-;|    |     ;    |
      *;     ,-*`  ||    |     /   ;;
        `^^`` |    ||    |   ,^    /
              |    ||    `^^`    ,^
              |  _,"|        _,-"
              -*`   ****"""``
    
    qutebrowser v2.5.4
    Git commit: a71c25c2a on master (2023-06-05 13:02:42 +0200)
    Backend: QtWebEngine 6.4.2, based on Chromium 102.0.5005.177 (from api)
    Qt: 6.4.2
    
    CPython: 3.11.4
    PyQt: 6.4.2
    
    sip: no
    colorama: 0.4.6
    jinja2: 3.1.2
    pygments: 2.15.1
    yaml: 6.0
    adblock: 0.6.0
    objc: no
    PyQt6.QtWebEngineCore: 6.4.0
    pdf.js: no
    sqlite: 3.40.1
    QtNetwork SSL: OpenSSL 3.0.9 30 May 2023
    
    Style: QFusionStyle
    Platform plugin: xcb
    OpenGL: Intel, 4.6 (Compatibility Profile) Mesa 22.3.6
    Platform: Linux-6.1.0-9-amd64-x86_64-with-glibc2.36, 64bit
    Linux distribution: Debian GNU/Linux 12 (bookworm) (debian)
    Frozen: False
    Imported from /home/ander/Desktop/qutebrowser/qutebrowser
    Using Python from /home/ander/Desktop/qutebrowser/.venv/bin/python
    Qt library executable path: /usr/lib/qt6/libexec, data path: /usr/share/qt6
    
    Paths:
    cache: /tmp/qutebrowser-basedir-fu41wzsl/cache
    config: /tmp/qutebrowser-basedir-fu41wzsl/config
    data: /tmp/qutebrowser-basedir-fu41wzsl/data
    runtime: /tmp/qutebrowser-basedir-fu41wzsl/runtime
    system data: /usr/share/qutebrowser
    
    Autoconfig loaded: yes
    Config.py: no config.py was loaded
    Uptime: 0:00:00
    

    Only line, that changes in meaningful way for each Python version, is ^CPython:.

  8. The-Compiler commented on Jun 8, 2023

    @The-Compiler
    Member

    Ah, looks like the Debian 3.11.3-2 from experimental isn't actually Python 3.11.3 if I'm reading the changelog right, but something entirely in between:

    • Update to the 3.11 branch 2023-05-30.

    But the 3.11.3 upstream release was actually from April 5th, and the offending change was merged on April 13th...


    With that mystery out of the way - reported to CPython and PyQt:

    It looks like a workaround is possible, though. I'm surprised Qt 5 seems to work fine, but it handles those things a little differently.


    From a first look through the source, if only inverting is the problem, those should be the only lines possibly affected:

    qutebrowser/keyinput/keyutils.py
    180:    assert not key_int & ~mask, hex(key_int)
    262:        modifiers &= ~altgr  # type: ignore[assignment]
    395:                int(combination) & ~Qt.KeyboardModifier.KeyboardModifierMask)
    422:            modifiers &= ~_MODIFIER_MAP[self.key]  # type: ignore[assignment]
    489:        mods = self.modifiers & ~modifiers
    672:        modifiers &= ~Qt.KeyboardModifier.GroupSwitchModifier
    705:                modifiers &= ~Qt.KeyboardModifier.ControlModifier
    708:                modifiers &= ~Qt.KeyboardModifier.MetaModifier
  9. added a commit that references this issue on May 1, 2024
    f80f454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: exceptionA Python exception gets thrown.component: keyinputIssues related to processing keypresses.priority: 0 - highIssues which are currently the primary focus.qt: 6Issues related to Qt 6.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions