Commit 7f21de6
committed
[Python] Don't exploit garbage collection hooks for memory relgulator
Looking at the CPPInstance, I noticed that is claims to support cycling
garbage collection via the `Py_TPFLAGS_HAVE_GC` for not the right
reasons. It doesn't stick at all to the contract explained in the docs:
https://docs.python.org/3/c-api/gcsupport.html#c.PyObject_GC_Track
The `tp_traverse` and `tp_clear` implementations actually do nothing
with the C Python API, and the class also doesn't implement a custom
`tp_alloc` and `tp_free`.
I think the CPPInstance tries to exploit the python garbage collector to
trigger its own memory regulator code path, but breaking some of the
Python C API contracts on the way.
This might be the reason for the spurious failures in the CI, which
happen *between* two tests, hinting to garbage collector problems.
I think it's particularly problematic that the CPPInstance never
registers itself to the GC with `PyObject_GC_Track`, but then uses
`PyObject_GC_UnTrack`. That probably brings the garbage collector in a
bad state.1 parent 3ab1d5c commit 7f21de6
1 file changed
+4
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
450 | | - | |
451 | 449 | | |
452 | | - | |
453 | | - | |
454 | 450 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 451 | + | |
| 452 | + | |
464 | 453 | | |
465 | 454 | | |
466 | 455 | | |
| |||
1086 | 1075 | | |
1087 | 1076 | | |
1088 | 1077 | | |
1089 | | - | |
1090 | | - | |
| 1078 | + | |
1091 | 1079 | | |
1092 | 1080 | | |
1093 | | - | |
| 1081 | + | |
1094 | 1082 | | |
1095 | 1083 | | |
1096 | 1084 | | |
| |||
0 commit comments