Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should build using -DPERL_USE_SAFE_PUTENV on Linux #19399

Closed
leonerd opened this issue Feb 7, 2022 · 1 comment · Fixed by #19514
Closed

Should build using -DPERL_USE_SAFE_PUTENV on Linux #19399

leonerd opened this issue Feb 7, 2022 · 1 comment · Fixed by #19514

Comments

@leonerd
Copy link
Contributor

leonerd commented Feb 7, 2022

This compiletime flag affects the way perl interacts with the putenv() libc call.

Without it, subtle memory corruption happens if both perl and some other C library attempt to putenv() within the same program. This corruption is only detected at destruction time, and only on thready+debugging builds.

An example of this can be seen in https://rt.cpan.org/Ticket/Display.html?id=140138

I believe the solution is simply that Perl should build using this flag all the time.

@leonerd
Copy link
Contributor Author

leonerd commented Mar 10, 2022

I should add: The reason the logic is conditional, is that it has to work around a bug in glibc 2.0 and 2.1.1

glibc 2.1.1 was released in May 1999, and glibc 2.1.2 fixed the bug in September of that year. No glibc release this century has the bug that we're trying to work around.

I think it's safe to just enable it by default on Linux now ;)

xenu added a commit to xenu/perl5 that referenced this issue Mar 10, 2022
...but only on the platforms that have setenv() and unsetenv().

Fixes Perl#19399
xenu added a commit to xenu/perl5 that referenced this issue Mar 10, 2022
...but only on the platforms that have setenv() and unsetenv().

Fixes Perl#19399
xenu added a commit to xenu/perl5 that referenced this issue Apr 19, 2022
Now environ isn't owned by Perl and calling setenv/putenv in XS code
will no longer result in memory corruption.

Fixes Perl#19399
xenu added a commit to xenu/perl5 that referenced this issue May 28, 2022
Now environ isn't owned by Perl and calling setenv/putenv in XS code
will no longer result in memory corruption.

Fixes Perl#19399
xenu added a commit to xenu/perl5 that referenced this issue May 28, 2022
Now environ isn't owned by Perl and calling setenv/putenv in XS code
will no longer result in memory corruption.

Fixes Perl#19399
xenu added a commit that referenced this issue May 28, 2022
Now environ isn't owned by Perl and calling setenv/putenv in XS code
will no longer result in memory corruption.

Fixes #19399
scottchiefbaker pushed a commit to scottchiefbaker/perl5 that referenced this issue Nov 3, 2022
Now environ isn't owned by Perl and calling setenv/putenv in XS code
will no longer result in memory corruption.

Fixes Perl#19399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant