Skip to content

[3.8] bpo-37931: Fix crash on OSX re-initializing os.environ (GH-15428)#17488

Merged
miss-islington merged 1 commit into
python:3.8from
miss-islington:backport-723f71a-3.8
Dec 6, 2019
Merged

[3.8] bpo-37931: Fix crash on OSX re-initializing os.environ (GH-15428)#17488
miss-islington merged 1 commit into
python:3.8from
miss-islington:backport-723f71a-3.8

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented Dec 6, 2019

On most platforms, the environ symbol is accessible everywhere.

In a dylib on OSX, it's not easily accessible, you need to find it with
_NSGetEnviron.

The code was caching the value of environ. But a setenv() can change the value,
leaving garbage at the old value. Fix: don't cache the value of environ, just
read it every time.
(cherry picked from commit 723f71a)

Co-authored-by: Benoit Hudson [email protected]

https://bugs.python.org/issue37931

On most platforms, the `environ` symbol is accessible everywhere.

In a dylib on OSX, it's not easily accessible, you need to find it with
_NSGetEnviron.

The code was caching the *value* of environ. But a setenv() can change the value,
leaving garbage at the old value. Fix: don't cache the value of environ, just
read it every time.
(cherry picked from commit 723f71a)

Co-authored-by: Benoit Hudson <[email protected]>
Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good bot.

@miss-islington
Copy link
Copy Markdown
Contributor Author

@benoithudson and @vstinner: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 836cf31 into python:3.8 Dec 6, 2019
@miss-islington miss-islington deleted the backport-723f71a-3.8 branch December 6, 2019 19:32
@miss-islington
Copy link
Copy Markdown
Contributor Author

@benoithudson and @vstinner: Status check is done, and it's a success ✅ .

1 similar comment
@miss-islington
Copy link
Copy Markdown
Contributor Author

@benoithudson and @vstinner: Status check is done, and it's a success ✅ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants