GeezerVison is showing github.com — chore(deps): update dependency multidict to v6.9.1 [security] by renovate[bot] · Pull Request #52 · InseeFrLab/GRAAL
Conversation
This PR contains the following updates:
Multidict: Reference leak in CIMultiDict/MultiDict items-view union and subtraction
CVE-2026-104874 / GHSA-54p9-h82j-f925
More information
Details
Description
A reference leak in the items-view union and subtraction operators of aio-libs/multidict 6.7.0 through 6.9.0 (C extension) lets a remote client drive unbounded, unreclaimable memory growth by having each operand element leak one key-identity object and one value object. The reflected-union path (operand | d.items(), multidict_itemsview_or2_impl) and the subtraction path (d.items() - operand, multidict_itemsview_sub1_impl) parse each element into new strong references but release only the tuple wrapper, never the identity and value. Servers in the aio-libs stack build these views over attacker-supplied HTTP headers and query strings, so the operand size is under remote control. Forced garbage collection does not recover the leaked objects, so resident memory rises monotonically until the process is killed.
Root Cause
_multidict_itemsview_parse_item() returns new references: a fresh identity via md_calc_identity() and a fresh value via Py_NewRef(). The or2_impl first parse loop requests both but clears only arg:
// views.h:565 — or2_impl first parse loop
while ((st = PyIter_NextItem(iter, &arg)) > 0) {
int tmp = _multidict_itemsview_parse_item(
self, arg, &identity, NULL, &value); // identity + value: new refs
if (tmp < 0) goto fail;
else if (tmp > 0) {
if (_set_add(tmp_set, identity, value) < 0) goto fail;
}
Py_CLEAR(arg); // :575 clears arg ONLY
}
_set_add() builds its own tuple with PyTuple_Pack and Py_DECREFs it, so it never borrows the loop's identity/value. On the next iteration those variables are overwritten, so the previous references are lost permanently. The sub1_impl first loop (:686-696) has the identical omission.
This is an editing slip, not an ownership contract: every sibling path clears all three references per iteration, and1_impl (:304-306), and2_impl (:389-391), or1_impl (:506-508), and the second (md_next) loops of both functions (:605-607, :726-728). PR #1413 added a Py_DECREF(tpl) to the second loop of or2/sub1, fixing a different temporary-tuple leak; it never touched the first parse loop, so this leak remains on master.
views.h is byte-identical between v6.6.0 and v6.7.0, yet 6.6.4 does not leak and 6.7.0 does. The regression is behavioural, introduced by a key-identity ownership change in hashtable.h across that boundary that made md_calc_identity() return a fresh strong reference the unchanged parse loop never releases.
Reproduction Environment
| Item |
Value |
| Runtime |
CPython 3.14.6 |
| multidict |
6.9.0 (PyPI binary wheel, C extension) |
| OS |
macOS (darwin 25.6.0, arm64) |
Proof of Concept
POC Source Code
poc_refcount.py — leak proof with intersection control
import sys, gc
from multidict import CIMultiDict
def probe(name, run_op):
d = CIMultiDict(); d["seed"] = "x"
value = object() # unique sentinel
N = 100000
operand = [("k%d" % i, value) for i in range(N)]
gc.collect(); before = sys.getrefcount(value)
run_op(d, operand)
gc.collect(); after = sys.getrefcount(value)
print(f"[{name}] leaked strong refs = {after - before}")
probe("or2 operand | items", lambda d, o: o | d.items()) # reflected union
probe("sub1 items - operand", lambda d, o: d.items() - o) # subtraction
probe("and2 items & operand", lambda d, o: d.items() & o) # CONTROL: clears, expect 0
poc_dispatch.py — maps which paths leak
import sys, gc
from multidict import CIMultiDict
def probe(name, fn):
d = CIMultiDict(); d["seed"] = "x"
v = object(); N = 50000
operand = [("k%d" % i, v) for i in range(N)]
gc.collect(); before = sys.getrefcount(v)
fn(d, operand); gc.collect(); after = sys.getrefcount(v)
print(f"{name:35s} leaked={after - before}")
probe("operand | d.items() (or2)", lambda d, o: o | d.items())
probe("d.items() | operand (or1)", lambda d, o: d.items() | o)
probe("d.items() - operand (sub1)", lambda d, o: d.items() - o)
probe("operand - d.items() (rsub)", lambda d, o: set(o) - d.items())
probe("d.items() & operand (and)", lambda d, o: d.items() & o)
poc_rss.py — availability consequence
import sys, gc, resource
from multidict import CIMultiDict
def rss_mb():
r = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
return r / (1024 * 1024) if sys.platform == "darwin" else r / 1024
d = CIMultiDict(); d["seed"] = "x"
gc.collect(); print(f"start RSS = {rss_mb():.1f} MB")
for i in range(200):
operand = [(f"k{i}_{j}", f"v{i}_{j}") for j in range(50000)]
_ = operand | d.items()
del operand
gc.collect() # prove GC cannot reclaim the leak
if (i + 1) % 40 == 0:
print(f"after {(i+1)*50000:>9,} elements: RSS = {rss_mb():.1f} MB")
Execution Steps
python3 -m venv venv (CPython 3.10+).
./venv/bin/pip install "multidict==6.9.0" (installs the C-extension wheel).
- From a directory that is not a multidict checkout, run each script with
./venv/bin/python.
Actual Execution Evidence
[or2 operand | items] leaked strong refs = 100000
[sub1 items - operand] leaked strong refs = 100000
[and2 items & operand] leaked strong refs = 0 <- control
operand | d.items() (or2) leaked=50000
d.items() | operand (or1) leaked=0
d.items() - operand (sub1) leaked=50000
operand - d.items() (rsub) leaked=0
d.items() & operand (and) leaked=0
start RSS = 15.6 MB
after 2,000,000 elements: RSS = 288.1 MB
after 6,000,000 elements: RSS = 776.8 MB
after 10,000,000 elements: RSS = 1266.8 MB (gc.collect() every iteration)
Version-boundary evidence
Same poc_dispatch.py, PyPI wheels, identical environment. Last-clean is 6.6.4; first-affected is 6.7.0:
6.6.4 : or2=0 sub1=0 others=0 (clean, last 6.6.x)
6.7.0 : or2=50000 sub1=50000 others=0 (AFFECTED, first)
6.9.0 : or2=50000 sub1=50000 others=0 (affected)
The clean 6.6.x releases return correct set-operation results, so the zero leak reflects correct memory management, not a broken path.
Analysis of Results
The operand holds exactly N references to one sentinel value; after the union its refcount rises by another N and stays there post-GC, so each element leaked one strong reference. Subtraction shows the identical delta. The intersection control, which clears identity and value, leaks zero; the only code difference is the two missing Py_CLEAR calls, so the leak is caused by that omission and not the harness. RSS climbs from 15.6 MB to 1266.8 MB (~250 MB per 2M elements) despite per-iteration GC, confirming the objects are unreachable by the cyclic collector.
Impact
A process that evaluates items-view unions or subtractions over remote-influenced operands leaks one identity plus one value object per element, permanently. In the aio-libs stack multidict backs HTTP headers and query strings, so an attacker who enlarges the operand (for example, many repeated header items compared against a fixed allow/deny set) forces steady, unrecoverable heap growth and can eventually exhaust memory in a long-lived server. This is an availability defect only; results stay correct and no data is exposed.
Reachability depends on the application evaluating operand | view.items() (reflected union) or view.items() - operand (subtraction) over a sequence of 2-tuples whose count is remote-influenced. The forward union view.items() | operand routes to or1_impl, which clears correctly and does not leak; a non-tuple operand element takes the parse_item early-return and does not leak. Set algebra over items views is not the most common multidict usage, which bounds exposure and is why this is Medium, not High. This is distinct from PR #1413, which fixed a temporary-tuple leak in the second loop and did not release these per-element objects.
Remediation
Recommended fix. Clear the two per-element references at the end of the first parse loop in both functions, exactly as every sibling path does. In or2_impl (views.h:575) and sub1_impl (views.h:696), replace the lone Py_CLEAR(arg); with:
Py_CLEAR(arg);
Py_CLEAR(identity);
Py_CLEAR(value);
This is an in-repo change to a static internal function; it alters no public API, type, or signature, and asks callers to change nothing. A leak test in the existing tests/test_leaks.py style would lock it in.
Workaround. Avoid operand | view.items() and view.items() - operand on attacker-influenced operands, or install with MULTIDICT_NO_EXTENSIONS=1 to use the unaffected pure-Python build.
Severity
- CVSS Score: 5.3 / 10 (Medium)
- Vector String:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
aio-libs/multidict (multidict)
Compare Source
=====
(2026-09-21)
Bug fixes
-
Fixed the C extension reading freed memory on free-threaded builds when a
list handed to :py:meth:~multidict.MultiDict.update,
:py:meth:~multidict.MultiDict.extend, :py:meth:~multidict.MultiDict.merge
or the :py:class:~multidict.MultiDict and :py:class:~multidict.CIMultiDict
constructors, a [key, value] item inside any iterable handed to them, or a
list tested with in against :py:meth:~multidict.MultiDict.items, is
changed by another thread; a call that catches the list shrinking under it
now raises :py:exc:RuntimeError -- by :user:rodrigobnogueira.
Related issues and pull requests on GitHub:
:issue:1437.
-
Fixed a data race on the free-threaded build where a retired hash table's
reader count used relaxed atomics, letting a lock-free get()/getone()/
__getitem__() read race a concurrent free of that table. The reader-exit
decrement and the drain's free check now use release/acquire ordering
instead -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1481.
-
Fixed a free-threaded build bug where two threads calling update(),
merge(), or __setitem__() on the same key at the same time could lose
the key entirely instead of just racing on which value wins. A decref of the
replaced value could transiently suspend the writer's critical section,
letting a second writer for the same key observe the first writer's
in-progress entry as absent and, once both settled, mistake it for a stale
duplicate and delete it. Every such decref is now deferred until the writer
has released its critical section, so the window can no longer open.
setdefault() had an unrelated instance of the same blind spot (it could
insert a duplicate rather than recognizing an in-flight key), fixed alongside
it -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1483.
-
Fixed a free-threaded build bug where getall() and the items()/
keys()/values() equality path could raise KeyError or report a
present, never-deleted key as missing. A concurrent update()/extend()/
__setitem__() call can have its critical section transiently suspended
(a decref triggering a blocking allocator call) while an entry is marked as
part of its own bookkeeping; a reader landing in that window used to treat
the mark as "not found" instead of "still there, in flight" -- by
:user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1484.
-
Fixed a reference leak in the C extension where operand | md.items()
and md.items() - operand leaked one key and one value reference per
element of operand, letting a large operand grow memory without bound
(:gh:GHSA-54p9-h82j-f925 <aio-libs/multidict/security/advisories/GHSA-54p9-h82j-f925>)
-- by :user:asvetlov.
The issue was reported by :user:waydeshi.
Related commits on GitHub:
:commit:350b4a0.
-
Fixed a segmentation fault on the standard (non-free-threaded) C extension
build when a value type's __del__ released the GIL (for example by
calling time.sleep()) while update(), merge(), __setitem__(),
__delitem__(), pop(), popone(), or popall() was dropping a
replaced or removed value. Py_BEGIN_CRITICAL_SECTION compiles to a no-op
on this build, so nothing else was stopping a second thread from mutating the
very same MultiDict concurrently once the GIL was released mid-mutation.
Every such decref is now deferred until the mutation has fully finished, the
same technique already used to close the analogous free-threaded-build race
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1489.
-
Fixed the C extension reading freed memory while iterating a
:py:class:~multidict.CIMultiDict whose keys are plain :py:class:str.
Converting such a key to :py:class:~multidict.istr could run Python code
(a :py:class:str subclass's __str__ or __del__) or, on free-threaded
builds, suspend the iterator's critical section, after which the iterator read
the entry again even though a concurrent mutation could already have freed it.
As part of the fix, :py:meth:~multidict.MultiDict.copy and re-initializing
from another multidict now assign a new version in the C extension instead of
reusing the source's, matching the pure Python implementation
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1496.
-
Fixed a use-after-free on the free-threaded build where a lock-free
get(), [] or in could read a hash table that a concurrent
resize had just retired and another reader was freeing
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1497.
Contributor-facing changes
-
Removed a redundant include and a duplicated exclude line from
MANIFEST.in; sdist contents are unchanged -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1478.
-
Added .claudeignore file -- by :user:asvetlov
Related issues and pull requests on GitHub:
:issue:1479.
-
Scaled up the pure-Python pop(), popitem(), __delitem__(),
add() and item-insertion benchmarks to do more work per measurement.
Repeated CodSpeed runs on the same commit showed these particular
benchmarks flagged as dominated by syscalls, understating their real
cost and adding noise to the reported values; a larger working set
amortizes that overhead -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1485.
-
Replaced deprecated instrumentation codspeed mode with simulation -- by :user:asvetlov
Related issues and pull requests on GitHub:
:issue:1493.
-
Reorganized the mutating benchmarks (item insertion, update(),
add() of the same key, pop(), popitem(), clear(),
__delitem__() and __setitem__()) to copy a fresh multidict and
apply the operation in a loop, like the add() and extend()
benchmarks already do. The insertion, update() and clear()
benchmarks previously mutated a single multidict shared across
rounds, so only the first round measured the intended operation; the
rest did a single copy per round, letting per-round overhead dominate
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1494.
-
The repr() and view inequality benchmarks were updated to repeat their
operation in a loop, like the other benchmarks, and the CodSpeed benchmark
job was moved to Python 3.14 -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1498.
-
Dropped -I from the AddressSanitizer test command in AGENTS.md
and in the CI job. It implies -E, which made Python ignore
PYTHONMALLOC=malloc, so small hash tables were still served from
pymalloc arenas where use-after-free went undetected
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1499.
-
The CI/CD workflow was updated to stop superseded runs of the same pull request
when a new commit is pushed; runs on master, release branches, tags,
the merge queue, and the daily schedule are never interrupted
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1500.
-
The release job was changed to upload distributions and their signatures
to the GitHub Release one file at a time, skipping assets that were
already attached and retrying after a pause, so that a parallel upload
burst no longer tripped the GitHub secondary rate limit
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1503.
Miscellaneous internal changes
-
Corrected several comments in the free-threaded C extension that
attributed critical-section suspension to a blocking PyMem_Malloc()
call; allocation alone never suspends an acquired critical section, and
the real risk at those sites is a decref running
a finalizer or weakref callback. Also dropped a retry loop in
md_clone_from_ht() that guarded against the same, non-existent
allocation-triggered suspension -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1486.
-
Changed the free-threaded build's deferred decref buffer, used by
update() and __setitem__(), to a chain of fixed-size blocks
with a large inline first block instead of a small inline array that
was reallocated on growth -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1501.
Compare Source
==========
(2026-09-18)
Bug fixes
-
Protected repr() of MultiDict, MultiDictProxy, and their views
in the C extension with a critical section, avoiding data races on the
free-threaded build of CPython -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1431.
-
Guarded repr() of MultiDictProxy in the C extension and of
KeysView in both the C extension and the pure-Python
implementation against infinite recursion on self-referential
containers, matching the existing guard on MultiDict,
ItemsView, and ValuesView -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1431.
-
Protected MultiDict.update(), .extend(), .merge(), .clear(),
.copy(), and the MultiDict/CIMultiDict constructors in the C
extension with a critical section, using the two-object form when a
second multidict, multidict proxy, or plain dict instance is
involved, avoiding data races and a segmentation fault on the
free-threaded build of CPython. .clear() now also publishes the
empty table before releasing any entry's references, so a concurrent
caller can never observe a partially-cleared multidict even if releasing
a value runs arbitrary Python code that suspends the held critical
section -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1433.
-
Protected MultiDict.add(), __setitem__/__delitem__,
get()/getone()/__getitem__, __contains__, getall(),
setdefault(), pop()/popone()/popall()/popitem(),
__eq__, iteration, and the &/|/-/^/in/
isdisjoint() operations on .keys() and .items() views in the
C extension with a critical section, avoiding data races and
use-after-free crashes on the free-threaded build of CPython
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1438.
-
Fixed a data race on the free-threaded build where MultiDictObject.used
was written non-atomically while len() read it with a relaxed atomic
load -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1441.
-
Fixed several pre-existing use-after-free races on the free-threaded build: _md_resize()
and md_clone_from_ht() could allocate a new hash table, have their
critical section transiently suspended during that allocation, and then use
a keys-table pointer or size a concurrent operation had already invalidated;
_md_del_at() (plain del/pop()) could likewise leave self in
an inconsistent state across a suspending decref -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1441.
-
Fixed a data race on the free-threaded build where md->keys was
published with a plain store while lock-free readers loaded it
atomically, and a false-negative race in get()/__contains__
where a hash temporarily marked by a concurrent replace could make a
present key look absent -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1441.
-
Fixed several more pre-existing use-after-free and data-corruption races on
the free-threaded build, this time in the __setitem__()/update()/
extend()/merge() replace path: a decref suspending the critical
section mid-replace could leave a stale table pointer in use, misplace a
temporarily-marked entry during a concurrent resize, or let one thread's
duplicate-tracking mark get overwritten by an unrelated key's entry sharing
the same hash bucket -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1441.
-
Fixed an unbounded memory leak on the free-threaded build where a retired
hash table could sit on md->retired for the rest of the object's
lifetime under sustained concurrent read traffic instead of being freed
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1443.
-
Fixed a data race on the free-threaded build of the C extension where
state->global_version, the version counter shared by every
multidict instance and used to derive getversion(), was bumped with
a plain increment instead of an atomic op. Two threads mutating
different instances at the same time could step on each other's update
and hand out a duplicate (or non-monotonic) version number
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1444.
-
Fixed a data race on the free-threaded build of the C extension where
getall()/popall() and update()/extend()/merge()
temporarily marked and unmarked a matching entry's hash with a plain,
non-atomic store, while a lock-free __contains__/get() on another
thread could load that same field with an atomic operation and no lock at
all -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1448.
-
Fixed a data race in the pure-Python MultiDict/CIMultiDict
fallback where concurrent mutating calls (add(), __setitem__,
__delitem__, setdefault(), pop()/popone(),
popall(), popitem(), update(), extend(), merge(),
clear(), and re-__init__) could corrupt the shared hash table,
or silently drop a concurrent write, on a regular, GIL-enabled
interpreter. Pure-Python bytecode is not atomic under the GIL, so two
threads could interleave mid hash-table insert or deletion, leaving
the index table pointing at stale or out-of-range entries and causing
an infinite probe loop, an AttributeError, or a lost mutation.
Each MultiDict/CIMultiDict instance now holds its own lock for
the duration of these operations, with two-object operations locking
both instances in a fixed order to avoid deadlock. The C extension
already serializes these operations with a critical section and was
not affected
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1449.
-
Fixed a data race on the free-threaded build of the C extension where
to_dict() cleared every entry's temporary "seen" mark with a plain,
non-atomic store, while a lock-free __contains__/get() on another
thread could load that same field with an atomic operation and no lock at
all -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1450.
-
Fixed a data race on the free-threaded build of the C extension where
update()/extend()/merge() read self's module state without
holding self's lock, while a concurrent __init__() on the same,
already-published multidict could rewrite that same field under lock.
Rather than routing every read through a lock-free lookup, the field is
now written only once, at object construction, and never touched again by
__init__(), so it is safe to read unlocked anywhere -- by
:user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1452.
-
Fixed items() set algebra (&, |, -, in, isdisjoint()) so it no
longer corrupts or hangs when a compared value's __eq__() re-enters the
same :class:~multidict.MultiDict, for example by calling getall() on
it. The comparison now runs only after the internal hash-chain walk has
been fully materialized and restored, so the callback can no longer
observe entries the walk still has marked -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1453.
-
Fixed a data race on the free-threaded build of the C extension where
popall()/popone()/__delitem__/add() rewrote a hash table
index slot with a plain, non-atomic store, while a lock-free
get()/getone()/__getitem__/__contains__ on another thread
walked that same index array with a plain, non-atomic load and no lock at
all -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1454.
-
Stopped folding the case of :class:~multidict.istr keys in the
case-sensitive :class:~multidict.MultiDict, so both the C and the pure
Python implementations now keep such a key exactly as given
-- by :user:youdie006.
Related issues and pull requests on GitHub:
:issue:1457.
-
Fixed the C extension's update() (and merge(), which shares the same
code path) silently failing to invalidate an in-progress keys()/
items()/values() iterator when the call only overwrote an
already-present key's value in place. Adding a new key already invalidated
iterators correctly; only the in-place overwrite branch was missing the
version bump -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1458.
-
Fixed the pure-Python MultiDict/CIMultiDict iterator guard so that
mutating the mapping before the first next() call on an items(),
keys(), or values() iterator (or on iter(md)) now reliably raises
RuntimeError, matching the C extension. Previously a mutation that
happened before the iterator was ever advanced, such as clear() or a
del/popone() that removed the only remaining entry, could make the
iterator silently raise StopIteration instead -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1459.
-
Fixed a use-after-free race on the free-threaded build of the C extension
where a retired hash table could be freed while a lock-free
get()/getone()/__getitem__/__contains__ reader on another
thread was still walking it: the coarse "no reader in flight" gate
reaching zero did not reliably mean every such reader had also reached
its own per-table exit, so a table whose own reader count is still
nonzero is now deferred for a later retry instead of freed
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1461.
Features
-
Added a :meth:~multidict.MultiDict.to_dict method returning a plain
:class:dict that maps every key to the list of all its values. Unlike
dict(md), which keeps only the first value per key, and unlike a
{k: md.getall(k) for k in md} comprehension, which emits one entry per
spelling of a case-insensitive key, it groups by key identity
-- by :user:rodrigobnogueira.
Related issues and pull requests on GitHub:
:issue:783.
-
MultiDict, CIMultiDict, MultiDictProxy and CIMultiDictProxy in the
C extension implemented the vectorcall calling convention for construction.
This sped up MultiDict(...)-style calls by avoiding an intermediate
positional-arguments tuple and keyword-arguments dictionary in the common case; the gained burst is ~10.
-- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1436.
-
Made MultiDict.__contains__(), .get(), .getone() and
__getitem__() lock-free on CPython 3.14+'s free-threaded build, instead
of taking a critical section like the rest of the C extension's API (on
3.13, which lacks the public API these need to safely read an entry
concurrently, they still take the critical section, exactly as before). A
resize/shrink/clear no longer frees the outgoing hash table immediately; it
is deferred until no lock-free reader could still be walking it -- by
:user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1441.
-
Made the pure-Python MultiDict/CIMultiDict implementation safe to
use from multiple threads under a free-threaded (no-GIL) build. Every
method that touches an instance's hash table now takes that instance's own
lock, two-object operations (update(), extend(), merge(),
__eq__(), copying) lock both objects in a fixed, deadlock-safe order,
and the version counter shared by every instance is guarded separately. On
a regular (GIL-enabled) interpreter this adds no overhead: the locked
methods are the exact same function objects as before -- by
:user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1447.
-
Sped up adding many values for the same key to a
:class:~multidict.MultiDict or :class:~multidict.CIMultiDict, each
added value no longer gets slower than the one before it
-- by :user:bdraco.
Related issues and pull requests on GitHub:
:issue:1466.
Improved documentation
Contributor-facing changes
-
Added race tests that iterate and extend a :class:~multidict.MultiDict
from several threads on a free-threaded build, so a regression in the C
extension's locking fails a free-threaded CI leg instead of going unnoticed
-- by :user:rodrigobnogueira.
Related issues and pull requests on GitHub:
:issue:1317.
-
Added AddressSanitizer/UndefinedBehaviorSanitizer and
ThreadSanitizer CI jobs. The former runs the suite under a
regular CPython with MULTIDICT_ASAN_BUILD=1; the latter builds a
free-threaded CPython instrumented with --with-thread-sanitizer
and runs the suite against it via MULTIDICT_TSAN_BUILD=1 -- by
:user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1455.
-
Added Hypothesis-based property and stateful fuzz tests covering
:class:~multidict.MultiDict/:class:~multidict.CIMultiDict semantics,
views, iterators, and threaded stress scenarios, run against both the
C-extension and pure-Python backends -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1460.
-
Added core dump collection to the AddressSanitizer and ThreadSanitizer
CI jobs: a crash now uploads the core file alongside the crashing
interpreter binary and the compiled extension as a downloadable
artifact, for offline debugging with a matching symbol-carrying binary
instead of raw hex offsets -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1462.
-
Added benchmarks for adding many values for the same key and for
creating a multidict with many items -- by :user:bdraco.
Related issues and pull requests on GitHub:
:issue:1465.
-
Skipped abstractmethods from coverage leaks report, they are empty placeholders that are never executed -- by :user:asvetlov
Related issues and pull requests on GitHub:
:issue:1470.
-
Add benchmarks for __setitem__ -- by :user:asvetlov
Related issues and pull requests on GitHub:
:issue:1471.
-
The AddressSanitizer and ThreadSanitizer CI jobs were changed to run pytest
with --capture=no. Previously a sanitizer abort could exit the process
before pytest flushed its per-test output buffer, silently dropping the
sanitizer report from the job log -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1472.
-
Moved the hypothesis pin out of requirements/pytest.txt into its own
requirements/pytest-hypothesis.txt, installed only by the dedicated
Hypothesis CI jobs. hypothesis now ships a Rust extension with no
prebuilt wheel for some emulated architectures (e.g. musllinux i686),
which broke wheel-testing jobs that never run the Hypothesis-marked tests
in the first place -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1475.
Miscellaneous internal changes
-
Replaced PyIter_Next() calls with the newer PyIter_NextItem() API in
the C extension, so the iterator-exhausted and error cases are told apart by
the return code instead of an ambiguous NULL result -- by :user:asvetlov.
Related issues and pull requests on GitHub:
:issue:1440.
Configuration
📅 Schedule: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|