Title: crash reimporting posix after Py_Finalize on mac
Type: crash Stage: patch review
Components: Interpreter Core, macOS Versions: Python 3.9, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Benoit Hudson, miss-islington, ned.deily, ronaldoussoren, vstinner
Priority: normal Keywords: patch

Created on 2019-08-23 15:39 by Benoit Hudson, last changed 2019-12-06 19:32 by miss-islington.

File name Uploaded Description Edit
crashy.c Benoit Hudson, 2019-08-23 15:39
Pull Requests
URL Status Linked Edit
PR 15428 merged Benoit Hudson, 2019-08-23 16:07
PR 17488 merged miss-islington, 2019-12-06 19:15
Messages (4)
msg350309 - (view) Author: Benoit Hudson (Benoit Hudson) * Date: 2019-08-23 15:39
On OSX, with --enable-shared, if you shut down python and reinitialize, you can get a crash.

Repro steps: see attached crashy.c
gcc -I. -I ../Include/ -L. crashy.c -lpython3.9

On OSX, with --enable-shared, you get a crash! On other platforms including on OSX static builds, no crash.

Not a regression: it's present in 2.7 (where we actually hit it).

PR incoming, the fix is simple. It has to do with caching (on OSX shared builds only) a stale value for the environment when building os.environ the first time; if you change the environment, the second initialization reads garbage when building os.environ.
msg354387 - (view) Author: Benoit Hudson (Benoit Hudson) * Date: 2019-10-10 15:23
Ping! The patch has been ready for review for over a month.

If the patch can be backported to 2.7.x before that gets end-of-lifed it would be ideal.
msg357940 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 19:15
New changeset 723f71abf7ab0a7be394f9f7b2daa9ecdf6fb1eb by Victor Stinner (Benoit Hudson) in branch 'master':
bpo-37931: Fix crash on OSX re-initializing os.environ (GH-15428)
msg357942 - (view) Author: miss-islington (miss-islington) Date: 2019-12-06 19:32
New changeset 836cf31a3cf468ed9598a220b8e194b366287bfe by Miss Islington (bot) in branch '3.8':
bpo-37931: Fix crash on OSX re-initializing os.environ (GH-15428)
Date User Action Args
2019-12-06 19:32:39miss-islingtonsetnosy: + miss-islington
messages: + msg357942
2019-12-06 19:15:17miss-islingtonsetpull_requests: + pull_request16967
2019-12-06 19:15:16vstinnersetnosy: + vstinner
messages: + msg357940
2019-10-10 15:23:12Benoit Hudsonsetmessages: + msg354387
versions: + Python 2.7
2019-08-23 16:07:35Benoit Hudsonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request15125
2019-08-23 15:39:47Benoit Hudsoncreate