[issue45758] Crash on Py_DecRef'ing builtin object from previous run

2021-11-12 Thread Victor Milovanov


Victor Milovanov  added the comment:

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."

--
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45758] Crash on Py_DecRef'ing builtin object from previous run

2021-11-12 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

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.

--
nosy: +ronaldoussoren
resolution:  -> not a bug
stage:  -> resolved
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45758] Crash on Py_DecRef'ing builtin object from previous run

2021-11-09 Thread Hai Shi


Hai Shi  added the comment:

Hi, Victor Milovanov. The memory allocated by interpreter will be freed after 
calling Py_Finalize().

--
nosy: +pablogsal, shihai1991

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45758] Crash on Py_DecRef'ing builtin object from previous run

2021-11-08 Thread Victor Milovanov


New submission from Victor Milovanov :

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

--
components: C API
messages: 405987
nosy: Victor Milovanov
priority: normal
severity: normal
status: open
title: Crash on Py_DecRef'ing builtin object from previous run
type: crash
versions: Python 3.10, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com