mirror of
https://github.com/python/cpython.git
synced 2025-08-11 12:29:34 +00:00
[3.12] gh-91051: fix segfault when using all 8 type watchers (GH-107853) (#107876)
* gh-91051: fix segfault when using all 8 type watchers (GH-107853)
(cherry picked from commit 66e4edd734
)
Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
parent
f0a583b6fb
commit
00bfed7cba
6 changed files with 26475 additions and 26468 deletions
|
@ -147,7 +147,7 @@ Quick Reference
|
||||||
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
||||||
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
|
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
|
||||||
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
||||||
| [:c:member:`~PyTypeObject.tp_watched`] | char | | | | | |
|
| [:c:member:`~PyTypeObject.tp_watched`] | unsigned char | | | | | |
|
||||||
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
|
||||||
|
|
||||||
.. [#slots]
|
.. [#slots]
|
||||||
|
@ -2141,7 +2141,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
|
||||||
.. versionadded:: 3.9 (the field exists since 3.8 but it's only used since 3.9)
|
.. versionadded:: 3.9 (the field exists since 3.8 but it's only used since 3.9)
|
||||||
|
|
||||||
|
|
||||||
.. c:member:: char PyTypeObject.tp_watched
|
.. c:member:: unsigned char PyTypeObject.tp_watched
|
||||||
|
|
||||||
Internal. Do not use.
|
Internal. Do not use.
|
||||||
|
|
||||||
|
|
52921
Doc/data/python3.12.abi
52921
Doc/data/python3.12.abi
File diff suppressed because it is too large
Load diff
|
@ -82,5 +82,5 @@ typedef struct _typeobject {
|
||||||
vectorcallfunc tp_vectorcall;
|
vectorcallfunc tp_vectorcall;
|
||||||
|
|
||||||
/* bitset of which type-watchers care about this type */
|
/* bitset of which type-watchers care about this type */
|
||||||
char tp_watched;
|
unsigned char tp_watched;
|
||||||
} PyTypeObject;
|
} PyTypeObject;
|
||||||
|
|
|
@ -227,7 +227,7 @@ struct _typeobject {
|
||||||
vectorcallfunc tp_vectorcall;
|
vectorcallfunc tp_vectorcall;
|
||||||
|
|
||||||
/* bitset of which type-watchers care about this type */
|
/* bitset of which type-watchers care about this type */
|
||||||
char tp_watched;
|
unsigned char tp_watched;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This struct is used by the specializer
|
/* This struct is used by the specializer
|
||||||
|
|
|
@ -294,6 +294,18 @@ class TestTypeWatchers(unittest.TestCase):
|
||||||
C2.hmm = "baz"
|
C2.hmm = "baz"
|
||||||
self.assert_events([C1, [C2]])
|
self.assert_events([C1, [C2]])
|
||||||
|
|
||||||
|
def test_all_watchers(self):
|
||||||
|
class C: pass
|
||||||
|
with ExitStack() as stack:
|
||||||
|
last_wid = -1
|
||||||
|
# don't make assumptions about how many watchers are already
|
||||||
|
# registered, just go until we reach the max ID
|
||||||
|
while last_wid < self.TYPE_MAX_WATCHERS - 1:
|
||||||
|
last_wid = stack.enter_context(self.watcher())
|
||||||
|
self.watch(last_wid, C)
|
||||||
|
C.foo = "bar"
|
||||||
|
self.assert_events([C])
|
||||||
|
|
||||||
def test_watch_non_type(self):
|
def test_watch_non_type(self):
|
||||||
with self.watcher() as wid:
|
with self.watcher() as wid:
|
||||||
with self.assertRaisesRegex(ValueError, r"Cannot watch non-type"):
|
with self.assertRaisesRegex(ValueError, r"Cannot watch non-type"):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix abort / segfault when using all eight type watcher slots, on platforms
|
||||||
|
where ``char`` is signed by default.
|
Loading…
Add table
Add a link
Reference in a new issue