Message414060
> Oh wow. How did you find this leak? Did you read all C files and check for code specific to Windows? How did you proceed? Well spotted!
Initially, I modified Py_INCREF to dump the object (addr & tp_name) on
initial inc (ob_refcnt == 1) and Py_DECREF to dump on final dec
(ob_refcnt == 0).
Then filter that list (~65K) to find objects not dealloc'ed. Given
those names (~200), cross-check with source files containing 'ifdef
MS_WINDOWS' (and related spellings).
> Which command do you type? Do you pass -I option to Python?
For both as -I disables environment lookup:
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -757,6 +757,7 @@ config_init_defaults(PyConfig *config)
config->user_site_directory = 1;
config->buffered_stdio = 1;
config->pathconfig_warnings = 1;
+ config->dump_refs = 1;
#ifdef MS_WINDOWS
config->legacy_windows_stdio = 0;
#endif
For linux:
./configure --enabled-shared --with-py-debug --with-trace-refs
make build_all
LD_LIBRARY_PATH=$PWD ./python -X showrefcount -I -c pass
For Windows:
Add "#define Py_TRACE_REFS 1" to PC\pyconfig.h
build.bat -d -e
amd64\python_d.exe -X showrefcount -I -c pass
> I proposed GH-31594 to fix this macro.
Even using that change, I still have negative refs (but I still have
Py_TRACE_REFS defined) |
|
Date |
User |
Action |
Args |
2022-02-26 03:18:28 | jeremy.kloth | set | recipients:
+ jeremy.kloth, vstinner, jkloth |
2022-02-26 03:18:28 | jeremy.kloth | link | issue46857 messages |
2022-02-26 03:18:27 | jeremy.kloth | create | |
|