[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 51a29c42f10bd9368db9a21f2f63319be2e30b95 by Ken Jin in branch 
'3.9':
[3.9] bpo-44562: Remove invalid PyObject_GC_Del from error path of 
types.GenericAlias … (GH-27016) (GH-27028)
https://github.com/python/cpython/commit/51a29c42f10bd9368db9a21f2f63319be2e30b95


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread miss-islington


miss-islington  added the comment:


New changeset d17cc1ff9fe82b17bbe589b83e440959c8f135d7 by Miss Islington (bot) 
in branch '3.10':
bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias (GH-27021)
https://github.com/python/cpython/commit/d17cc1ff9fe82b17bbe589b83e440959c8f135d7


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset b324c4c5f763c5116a97db8591e6dcb94456570a by Pablo Galindo in 
branch 'main':
bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias (GH-27021)
https://github.com/python/cpython/commit/b324c4c5f763c5116a97db8591e6dcb94456570a


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25591
pull_request: https://github.com/python/cpython/pull/27031

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread Ken Jin


Change by Ken Jin :


--
pull_requests: +25587
pull_request: https://github.com/python/cpython/pull/27028

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-05 Thread STINNER Victor

STINNER Victor  added the comment:

> Revert "bpo-44562: Remove invalid PyObject_GC_Del from error path of 
> types.GenericAlias … (GH-27016) (GH-27018)" (GH-27022)

That's a good idea :-)

The reverted commit caused many segfaults on macOS:
https://buildbot.python.org/all/#/builders/108/builds/122

4 tests failed:
test_cmd_line_script test_multiprocessing_main_handling
test_tarfile test_trace

--
nosy: +vstinner

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset fe847a62852c3baaec6c97a5e2e7b2e66732bdb8 by Pablo Galindo in 
branch '3.9':
Revert "bpo-44562: Remove invalid PyObject_GC_Del from error path of 
types.GenericAlias … (GH-27016) (GH-27018)" (GH-27022)
https://github.com/python/cpython/commit/fe847a62852c3baaec6c97a5e2e7b2e66732bdb8


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +25581
pull_request: https://github.com/python/cpython/pull/27022

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +25580
pull_request: https://github.com/python/cpython/pull/27021

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> AFAIK PyType_GenericAlloc is used indirectly in ga_new(), but not in 
> Py_GenericAlias().

Oh, I see what you mean, that's a good point.

--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

AFAIK PyType_GenericAlloc is used indirectly in ga_new(), but not in 
Py_GenericAlias().

--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> But is alias->origin initialized to safely call Py_XDECREF(alias->origin)?

Why would that be unsafe? PyType_GenericAlloc sets all fields to NULL so that 
is going to either be NULL or have an object, no? setup_ga only sets 
alias->origin if there has been no failures

--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

But is alias->origin initialized to safely call Py_XDECREF(alias->origin)?

--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> And is is correct to call deallocator for not initialized GenericAlias object?

The correct thing to do is to call Py_DECREF so the object is properly unlinked 
and the other potential cleanups work. Calling the deallocator directly is 
almost always dangerous.

--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread miss-islington

miss-islington  added the comment:


New changeset 68330b681a4b63cedad58fcfd1d9573209bad21d by Miss Islington (bot) 
in branch '3.10':
bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias 
… (GH-27016)
https://github.com/python/cpython/commit/68330b681a4b63cedad58fcfd1d9573209bad21d


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 4684a34c8d2a2ffac7b779edb4ba57f043783478 by Miss Islington (bot) 
in branch '3.9':
bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias 
… (GH-27016) (GH-27018)
https://github.com/python/cpython/commit/4684a34c8d2a2ffac7b779edb4ba57f043783478


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is the same bug in ga_new(): tp_free is called directly.

And is is correct to call deallocator for not initialized GenericAlias object?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +25577
pull_request: https://github.com/python/cpython/pull/27018

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25578
pull_request: https://github.com/python/cpython/pull/27019

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset d33943a6c368c2184e238019c63ac7a267da5594 by Ken Jin in branch 
'main':
bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias 
… (GH-27016)
https://github.com/python/cpython/commit/d33943a6c368c2184e238019c63ac7a267da5594


--

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
pull_requests: +25575
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27016

___
Python tracker 

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Ken Jin


New submission from Ken Jin :

Ref: comment chain at 
https://github.com/python/cpython/pull/27008#discussion_r663450441.

setup_ga fails only if PyTuple_Pack fails, which usually happens when Python is 
out of memory. The cleanup code for setup_ga shouldn't use PyObject_GC_DEL as 
mentioned in Pablo's comment above.

I don't know how to add a test for out of memory, so I'll send a PR without 
test soon.

--
messages: 396944
nosy: kj, pablogsal
priority: normal
severity: normal
status: open
title: types.GenericAlias should decref instead of using delete in tp_new
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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