[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2022-03-18 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 2217462bda1865a047d358306088682ee6a091ed by Victor Stinner in 
branch 'main':
bpo-45786: Remove _PyFrame_Fini() and _PyFrame_DebugMallocStats() (GH-31874)
https://github.com/python/cpython/commit/2217462bda1865a047d358306088682ee6a091ed


--

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2022-03-14 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner
nosy_count: 2.0 -> 3.0
pull_requests: +29972
pull_request: https://github.com/python/cpython/pull/31874

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2022-01-13 Thread Mark Shannon


Mark Shannon  added the comment:

With https://bugs.python.org/issue45963 both frame objects and generators 
contain space for the frame, so no allocation occurs on exit.

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2021-11-29 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 60929576e40038ec71d896230f69e4411c82be4b by Mark Shannon in 
branch 'main':
bpo-45786: Allocate space for frame in frame object. (GH-29729)
https://github.com/python/cpython/commit/60929576e40038ec71d896230f69e4411c82be4b


--

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2021-11-23 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2021-11-11 Thread Mark Shannon


Mark Shannon  added the comment:

Ok, so it is not as bad as I thought.

A failed allocation might leave us with an invalid frameobject, though. So it 
is still worth fixing.

--

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2021-11-11 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Allocating memory can invoke GC

Technically, only allocating objects can trigger GC (specifically initializing 
them). All the malloc APIs don't currently call the GC by themselves.

--

___
Python tracker 

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



[issue45786] Avoid allocating when exiting frame; it may be unsafe.

2021-11-11 Thread Mark Shannon


New submission from Mark Shannon :

We exiting a frame (returning from a Python function) we have to release the 
stack allocated frame. If a heap-allocated frame object exists, we need to copy 
the contents of the (stack) frame into the frame object.
However, this involves allocating memory for the copy. Allocating memory can 
invoke GC, causing arbitrary code to be run, or the allocation can fail. Either 
leaves us in a precarious state, which may be unsafe.

I haven't been able to produce a crash, but I'm not sure that there isn't a 
potential crash lurking there either.

The fix is fairly simple. Allocate space for the copy of the frame at the end 
of the frame object. Then we need to copy the data, space will have already 
been allocated, and nothing can fail.

Since, in theory, heap-allocated frames are relatively rare, the extra memory 
used won't be an issue.

--
assignee: Mark.Shannon
components: Interpreter Core
keywords: 3.11regression
messages: 406163
nosy: Mark.Shannon, pablogsal
priority: normal
severity: normal
status: open
title: Avoid allocating when exiting frame; it may be unsafe.
type: crash
versions: Python 3.11

___
Python tracker 

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