- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue45758
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2021-11-08 23:07 by Victor Milovanov, last changed 2022-04-11 14:59 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg405987 - (view) | Author: Victor Milovanov (Victor Milovanov) | Date: 2021-11-08 23:07 | |
Trying to Py_DecRef owned reference to builtin "iter" crashes if the reference was alive when runtime was reinitialized. Py_Initialize(); PyObject* builtins = PyEval_GetBuiltins(); PyObject* iter = PyDict_GetItemString(builtins, "iter"); Py_IncRef(iter); Py_Finalize(); // ----- new run starts, iter should still be alive Py_Initialize(); Py_DecRef(iter); Py_Finalize(); // fails inside PyGC_Collect -> validate_list Related on StackOverflow: https://stackoverflow.com/questions/69890182/is-it-safe-to-call-py-decref-on-an-object-created-before-the-last-py-initializ |
|||
| msg406075 - (view) | Author: Hai Shi (shihai1991) * ![]() |
Date: 2021-11-10 07:01 | |
Hi, Victor Milovanov. The memory allocated by interpreter will be freed after calling Py_Finalize(). |
|||
| msg406204 - (view) | Author: Ronald Oussoren (ronaldoussoren) * ![]() |
Date: 2021-11-12 10:45 | |
IMHO your code is buggy, as Hai Shi also indicates. After Py_Finalize all objects in all (sub-)interpreters are deallocated unless there are bugs in the interpreter. Because of this "..., item should still be alive" in your sample code is incorrect: the reference should be considered to be invalid and cannot be used again. |
|||
| msg406228 - (view) | Author: Victor Milovanov (Victor Milovanov) | Date: 2021-11-12 18:03 | |
I think documentation should clarify that. Right now this line in the docs got me thinking that anything with an external strong reference won't be deallocated: "Memory tied up in circular references between objects is not freed." |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:52 | admin | set | github: 89919 |
| 2021-11-12 18:03:36 | Victor Milovanov | set | status: pending -> open messages: + msg406228 |
| 2021-11-12 10:45:52 | ronaldoussoren | set | status: open -> pending nosy: + ronaldoussoren messages: + msg406204 resolution: not a bug stage: resolved |
| 2021-11-10 07:01:02 | shihai1991 | set | nosy:
+ shihai1991, pablogsal messages: + msg406075 |
| 2021-11-08 23:07:35 | Victor Milovanov | create | |



