Qt — Reporting Bugs Upstream
[[[appendices.qt]]]
Overview
[[[appendices.qt#overview]]]
How a Qt or PySide6 bug found here becomes a report on bugreports.qt.io: what to write,
how to write it so it is read, and what to do once it is posted. The first report made this way was PYSIDE-3511
(#651); qt-repros/qimagereader_getter_keeps_gil.py and its .md, beside the work queue, are the worked example,
with #652's collected_qobject_takes_gil_under_mutex pair.
1. Two files per report
[[[appendices.qt#two-files]]]
Each report is a pair in qt-repros/ beside the work queue, outside every checkout:
<name>.py: a self-contained reproducer. One file, PySide6 only, its dependencies in a PEP 723# /// scriptblock (requires-python,PySide6-Essentials), run byuv run <name>.py. It is attached to the Qt report.<name>.md: how to fill the Jira form, field by field ([[appendices.qt#jira-form]]). The owner posts; nothing is filed from a session.
2. The reproducer is ordinary, supported Qt code
[[[appendices.qt#qt-way]]]
A Qt Company reviewer dismisses a report whose code is not the Qt way of doing things ("you are not supposed to do that") without looking at the bug. So the reproducer reads like a small, well-behaved application:
- Qt's own facilities first. A
QThreadPoolrunningQRunnables, not Python'sthreading; aQTimerdriving the GUI thread's work; signals and slots (Signal,@Slot) betweenQObjectsubclasses. Python's standard library only where Qt has no equivalent. - Nothing a Qt developer would call misuse. Every object lives on the thread that made it; a
QImageReadernever outlives its device; no stop flag on a pool task -- bounded tasks andwaitForDone()instead. - A familiar shape. Name things after what an application does (a thumbnail loader, a job and the listener that follows it), not after the bug.
- Ordinary Python. Lifetimes follow from the code's shape (a temporary, a local), never from
deltricks; no__import__, no reaching into private names. - Each choice that exposes the bug is marked. The module docstring lists them, numbered and explained, and a
# Exposes the bug (n): ...comment sits on the line that makes each one, so the reviewer sees at once which lines are the bug and that everything else is supported use. A loop that only turns a rare race into a frequent one says so. - The reviewer's first objection is answered first. When the bug itself breaks a Qt rule (#652: a
QObjectdestroyed off its thread), the docstring and the Description say up front who breaks it: PySide, not a line of the script.
3. Skimmable
[[[appendices.qt#skimmable]]]
- The module docstring says what the bug is, how the two sides meet, which choices expose it, how to run the script, what each exit code means, and how long to wait: a deadlock is silent until the watchdog fires.
- Every function and class has a docstring that says why it exists, not only what it does; comments only where the
why is not obvious. Our code conventions hold ([[appendices.code-conventions#python]]):
Finalconstants with docstrings, Sphinx docstrings,@override, no_names. - A deadlock runs in a child. A deadlocked process cannot report or end itself (exit waits on the same locks), so
main()only routes:run_harness()starts the same file again as the child and reports or kills it, andrun_child()runs the loops under faulthandler's watchdog, which prints every thread's Python stack without needing the GIL. Each says so in its docstring. - A
--with-format-style flag runs the workaround, so the report shows the same script running clean. The workaround is the one the app uses, and it removes the cause rather than narrowing the window: #652's first one, adeleteLater()alone, still let the collector reach the object before the event loop did; a parent does not.
4. Proving it
[[[appendices.qt#proving]]]
- Search Jira by the symptom once it is narrowed, through the REST API
(
/rest/api/2/search/jql?jql=project = PYSIDE AND text ~ "..."). #659's "a base class's slot outlives its widget" narrowed to a base class's name-mangled method, andtext ~ "mangled"found PYSIDE-3376, its other symptom (sender()isNonethere), already fixed in 6.12.0: no report, the issue closed with its measurements. - Measure the mechanism before writing the script. Experiments in the scratchpad, then native stacks of a hung run
(
py-spy dump --native --pid <child pid>) showing each side holding what the other waits for. The issue's guess at the trigger can be wrong (#651's GUI side was a deletion, not a property assignment; #660 blamed~KeypadModifier, which loses onlyGroupSwitchModifier, where~ShiftModifierloses Ctrl). - A bug guessed at, never seen, is not a report. #661's
QTimer.singleShot(ms, receiver, callable)that never fired was #506's guess at a coverage gap, made before the uncovered lines were read (they werestop()'s kill branch); its workaround, a memberQTimer, went into the lessons though it was never written. The call fires on 6.11.1, 6.11.3 and 6.12.0 / Python 3.14.6 and 6.12.0 / 3.15.2, in a plain app and under pytest-qt: not reproduced. - A stall is not a deadlock. Busy Python threads can starve the GUI thread of the GIL for long enough to look hung
(#652's first experiments). A real deadlock leaves the process near 0% CPU and its stacks unchanged between dumps.
Measure and dump the real interpreter: a venv's
python.exeis a launcher stub, always idle, whose child is the process to read. - Each cause the report names is checked by taking it away. #652 says the connection between job and listener
takes
~QObjectinto Python: a copy of the script without theconnectran clean, and the report says so. #651's "each job must be new" was checked the same way after posting: one long-lived job ran clean on 6.11 and 6.12. - The version matrix: PySide6 6.11 / Python 3.14, 6.12 / 3.14 and 6.12 / 3.15, by
uv run --python 3.x --with "PySide6-Essentials==6.1x.*" <name>.py.==6.11.*resolves to the newest patch, not the app's locked one, and--python 3.14beside 6.12 once ran on 3.15 (#653): ask for the full version (3.14.6), and name the exact versions the script printed. The C++ twin likewise runs on the newest 6.11 and 6.12 installs. No older releases: the latest 6.11 and 6.12 are enough for a report, and Qt 5 is out of support (owner, after #668's sweep of 6.3 to 6.10 and 5.15.2). - Rerun after every change to the script, both the failing run and the workaround run, the workaround on every combination too.
- Before handing over, read the pair against each other: the script's docstring, the Description and the stacks tell one story (#652's docstring named one GIL path while its stack showed another).
4.1 Mechanisms found so far
[[[appendices.qt#mechanisms]]]
~QObjectreaches Python under the signal-slot mutex. While holding its own mutex it calls each sender'smetaObject()anddisconnectNotify; for a Python-built sender, PySide takes the GIL in either: inretrieveMetaObject(a Python subclass's meta-object), or inSbk_GetPyOverridelooking for a PythondisconnectNotify, only on that object's first lookup, the "no override" answer then cached per object. Both were caught in native stacks (#651, #652). A reproducer needs a fresh sender each time; a plaindisconnectunlocks before notifying, and never deadlocks (#654's mechanism too).- The thread under the mutex can be Qt's own. Qt Multimedia's FFmpeg backend deletes, on its threads, objects it
connected to a Python-built
QAudioOutput, and that output's firstdisconnectNotifylookup takes the GIL there; the GUI thread meets it insetAudioOutput, which PySide calls with the GIL held (#654, PYSIDE-3514). To name the wrapper a native stack only shows as its module, answer its lookup early (connect and disconnect one of its signals on the GUI thread) and see the deadlock go. Several instances side by side (four players) turned a deadlock in half the runs into one in every run. - A worker's queued
emitis never one side. PySide releases the GIL aroundQMetaObject::metacalland takes it back only for the sender'smetaObject(), under no Qt lock;queued_activatecopies the arguments, aPyObjectWrappertaking the GIL, outside the receiver's mutex (PySide and Qt 6.11.1 and 6.12.0). A worker idle inemitis waiting for the GIL like any other thread: look for the thread that holds it. Emitting at a listener the GUI thread was destroying, its mutex held and the GIL wanted, ran clean on every version (#655). - A clean run counts only beside a control that deadlocks. #655's first "clean" runs never put the GUI thread
where the write-up said:
~QObjectcalls a sender'sdisconnectNotifyholding only the dying object's own mutex, and only for its incoming connections. The control (the same GUI loop against a PySidedisconnecton an object sharing that pooled mutex,shiboken6.getCppPointer(o)[0] % 131) deadlocked at once, with the expected stacks. - A getter moves what it returns under its caller. PySide is generated with the return value heuristic: a
method returning a
QObjectmakes the result's wrapper a Python child of the object it was called on, taken from the Python parent it had (exempt: names starting withparent, static methods, those with an ownership rule). When that caller is a Python-made object and is deleted, shiboken invalidates its Python subtree recursively: every wrapper of a Qt-made object in it reads "already deleted" while Qt still holds the object; Python-made ones are skipped.subWindow.mdiArea(), then that sub-window closed, killed the other documents'addWidgetactions (#656, PYSIDE-3515);nextInFocusChain()andQLabel.buddy()move theirs too,window()does not. A wrapper freed with children does the same, with nothing deleted in C++: PySide wraps a Qt-made object it has no wrapper of for one call (a slot's argument, an event filter'swatched), a getter called on it moves a Python tree under that wrapper, and the wrapper is freed as the call returns. #461'scontainer.dockWidget()in a pin's slot killed a line edit's own actions that way (#365, #658); in PySide alone,watched.childAt()on a scroll area's viewport does (qscrollarea_viewport_childat_invalidates_wrappers, a comment on PYSIDE-3515). Asked for once by a getter (scroll_area.viewport()), such an object has a lasting wrapper and nothing is freed. Read the chain withshiboken6.dump(obj)'sparentline. shiboken6.dumpon 6.11.1 faults on a wrapper with an invalid neighbor. It callsstr()on the wrapper's Python parent, children and referred objects, never on its own C++ object;str()of an invalid one raises, and 6.11.1 dereferences the NULL. An invalid wrapper stays in its Python parent's child list (Qt deleting an object it made only clears the wrapper's flag), so a live, valid line edit whose clear action Qt deleted faults. Fixed in 6.11.2. #631's "valid while gone" wrappers were this, not freed objects (#657): probe with 6.11.2 or later.- A negative flag member breaks
~for its whole class on Python 3.14. On Windows, shiboken gives a flag member with bit 31 set a negative value (KeyboardModifierMask,0xfe000000, reads-0x2000000); Python 3.14'senumthen makes_flag_mask_negative, and~memberkeeps only the bits below that member:~ShiftModifieris0x1ffffffon 6.11.1, 6.11.3 and 6.12.0, and fine on 6.12.0 / 3.15.2. A pure-PythonFlagwith the same negative member does the same. PYSIDE-3507's fix makes flag values unsigned only from Python 3.15, so 3.14 stays as it is (#660: no report). - A context connection outlives its method's owner. PySide keeps a bound method's
selfas a borrowed pointer and disconnects by weak reference when it dies, through a table the connect overload taking a context never fills (qobjectConnectCallback, noregisterSlotConnection).QTimer.singleShot(ms, context, o.m)above 0 ms, orQObject.connect(sender, SIGNAL(...), context, o.m), withoa plain object nothing else holds, callsmon freed memory: anAttributeErrorfor an attribute__init__set (3.14) or an access violation (3.15), on 6.11.1, 6.11.3 and 6.12.0. Without a context, or at 0 ms, it is safe (#671, PYSIDE-3517, found validating #661). - A style's
unpolishcan undo what itspolishnever did.QWindows11Style::unpolishsets every scroll area's viewportautoFillBackgroundfrom_q_original_autofill_background, whichpolishstores only for a styled-panelQTextEditorQPlainTextEdit(from 6.11.2; before, for any styled-panel scroll area). Unset, it reads false, and a stylesheet set on any shown ancestor re-polishes the views below it: a frameless view is then drawn in the window's color. A framed one loses the flag too but is still drawn in Base, the style painting the framed panel itself. 6.9.2 keeps the fill; 6.9.3 to 6.12.0 lose it (#662, QTBUG-152290). Compare such a flag across versions, not pixels: before 6.9.3 the style replaced the viewport's palette, so Base read black. - A stylesheet removed before the first polish leaves
WA_StyleSheetset.QStyleSheetStylesets the attribute the first time a widget asks it anything (initWidget), and aQFrameasks at once, for its frame width onStyleChange; onlyunpolishclears it, andsetStyle_helperunpolishes only a polished widget. Set and cleared before the first show, with nothing polishing it in between, the attribute stays, and the widget inherits neither palette nor font again. A widget cleared after it was shown is fine, so #621's "kept for good once set" was this narrower case. Any style, the same guard since Qt 5.15 (#663, QTBUG-152291). - Inline
nowraponly keeps spaces from breaking.<nobr>or a span'swhite-space:nowrapturns each space into a no-break space as the HTML is imported, and layout still breaks wherever Unicode allows: afterT:before a\, after a/. An inlineprebreaks at its spaces too. Only a block'swhite-space(nowraporpre) makes its lines unbreakable. Known since 2007 (QTBUG-1135, its duplicates QTBUG-12057 and QTBUG-54787), and the block form is Qt's own advice there, so it is not a workaround to remove; the same on 6.11.3 and 6.12.0 (#664, no report). - A palette color can carry alpha, and
QColor.name()drops it.QToolTip.palette()'sPlaceholderTextis its text at half alpha (#80000000light,#80ffffffdark) under windows11, fusion and windowsvista, on 6.11.3 and 6.12.0; throughname()it reads as the text itself. Print a color withname(QColor.NameFormat.HexArgb). Rich text takes the role by name,color:palette(placeholder-text), resolved each time the text is parsed: a color written in once stays the light one on a dark tooltip after a live theme switch (#665, not a bug). - A slider's absolute-set press acts before
sliderPressed, in every style.QSlider::mousePressEventsets the position, triggersSliderMoveand only then sets the slider down:actionTriggered(SliderMove),valueChanged,actionTriggered(SliderMove)again,sliderPressed. The style only picks the button: windows11 gives the left button absolute set and no button page set, fusion and windowsvista the middle button absolute set, and their middle press logs the same order, on 6.11.3 and 6.12.0 (#666, not a bug). - A disabled widget shows no cursor of its own, and
cursor()still returns the one set.qt_qpa_set_cursorclears the cursor over a disabled widget, and an enter on a disabled child takes its nearest enabled ancestor's. A disabledQSplitterHandlereportsSplitHCursororSplitVCursorand shows the arrow, under windows11, fusion and windowsvista, on 6.11.3 and 6.12.0: read what Windows shows (GetCursorInfo), not the property (#667, not a bug). - A list view tells accessibility any current row is its own.
QListView::currentChangedsends the current index's row as the Focus event's child, andQAccessibleTable::focusChildanswers with it, neither checking it is underrootIndex(). In aQColumnView, the column holding the current row has the view's selection model and the focus, so a click on a row in an earlier column makes it name its own row with that number, or logQAccessibleList::child: Invalid indexpast its end, on 6.11 and 6.12 (#668, QTBUG-152295).QAccessible::updateAccessibilityresolves the child whenever accessibility is active:QAccessible.setActive(True)reproduces it, and only in the active window, since the event needshasFocus(). PySide has noinstallUpdateHandler, so a script reads the focused widget'sfocusChild()as the click is reported; a focusable widget beside the view takes the focus first, so the log is a label. - Under a style sheet, a line edit's text keeps the old color scheme. After a runtime
QStyleHints.setColorScheme()switch, aQLineEditunder any style sheet (its own, or an ancestor's naming noQLineEdit) draws its text in the previous scheme's color whilepalette()already holds the new one. windows11 fills it from the new scheme, so the text can become unreadable; fusion keeps the whole old look. A hand-set palette'sTextfollows the switch. Without a style sheet, windows11 fills a line edit from its scheme's tables, not the palette'sBase, which only shows whenBaseis set by hand; rehuco themes by scheme, and the app showed neither. Known as QTBUG-125110, on 6.11.3 and 6.12.0 (#672, no report). - One
uv runof a script at a time. Parallel runs of the same PEP 723 script race on its cached environment and fail to install. - The cyclic collector runs on whichever thread allocates. Ordinary Python work on a pool thread can free a
live, Python-owned
QObjectcaught in a reference cycle there, and shiboken releases the GIL to run its C++ destructor (#652). - PySide releases the GIL around its own
connect, but not around a Qt call that connects internally: aQToolButtonre-applies its default action, with a freshconnect, at every change of that action (#529), orQMediaPlayer's constructor, whose backend connects its own signals (#653). PySide's owndisconnectkeeps the GIL while it waits for the mutex (#653's experiments).
5. The Jira form
[[[appendices.qt#jira-form]]]
The .md follows the order Jira's form shows its fields in, one heading per field: Project (Qt for Python,
PYSIDE), Issue Type (Bug), Summary, Description (straight after the Summary, not last), Priority (left
at Not Evaluated), Affects Version/s, Component/s (PySide), Environment, Attachment (the .py).
A bug in Qt itself goes to Qt (QTBUG) instead, its component the module's (Widgets: Styles for #662), and its
Summary starts with Qt's regression tag when a release that worked is known ([Reg 6.9.2 -> 6.9.3]). It carries a
second attachment, the same program in C++ (one .cpp, its CMakeLists.txt in the top comment, built against the
Qt installs in C:\Qt), so the report cannot be read as a PySide matter. From #663 on, a four-line <name>.pro
is attached with it: a qmake project keeps the reproducer's name, so the tester builds without writing a file.
A reproducer for something seen keeps its window open: it shows the result in a label and prints it when the
window is closed, and a --no-wait flag ends it by itself for the version matrix. It shows the state before the
change for a second or two, so the tester sees both, and a flag sets that pause (#663: --light-ms=0 for
scripted runs). When nothing on screen is wrong, the program shows what is: #668's first reproducer only
logged a warning, and the owner clicking it saw no bug. It now prints, for every click, its own and the tester's,
the item clicked beside the item accessibility reports, marked OK or WRONG.
- The Description is plain Markdown, written unfenced in the
.md: the owner opens VS Code's Markdown preview and drags the rendered text into Jira's Description field, which takes no raw wiki text. Real###subheadings, bold labels (Expected, Actual, Workaround, Suggested fix), stacks in a code block. - The one-line fields go in fenced blocks, copied as plain text. The file disables MD013 with a comment, since those blocks stay unwrapped.
6. After it is posted
[[[appendices.qt#after-posting]]]
- Read the posted issue through Jira's REST API (
https://qt-project.atlassian.net/rest/api/2/issue/<KEY>; the browse page renders in JavaScript): every field, the description's formatting, and the attachment downloaded and compared byte for byte with the local.py. - Our issue gets a comment linking the Qt issue, and two labels:
upstream bugandpending cleanup. The script stays on the Qt issue only. - A reported issue stays open until Qt fixes it, out of the release's milestone: it now tracks the Qt issue, so
the workaround is removed when the fix ships (
gh issue list --label "upstream bug"lists them). Its last comment gives each version's outcome, where the findings differ from the issue, and the workaround to remove, by file or rule. When the fix ships: rerun the reproducer on that version, remove the workaround, close. - An issue that did not reproduce, or was not a bug of its own (#655), is closed as not planned with its measurements.