-
Notifications
You must be signed in to change notification settings - Fork 556
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
Embedded perl and putenv() don't always play nicely #339
Comments
From Chris.Mihaly@disney.com Some recap on events. We were using perl 5.005_02 and have several We then rebuilt perl 5.005_03 with the patch from Gurusamy. We first We then went back to EMBEDMYMALLOC which caused perl to use system I have no solution for this. The original way causes core dumps Chris Gurusamy Sarathy wrote:
-- |
From [Unknown Contact. See original ticket]Chris Mihaly writes:
(Chris, I'm a baby porter, so don't take anything I say as holy Given that Perl can't assume anything about how the process implements It appears that Perl can't use the process's environment space. If Am I smoking crack? Nat |
From [Unknown Contact. See original ticket]On Thu, 5 Aug 1999, Nathan Torkington wrote:
The approach you're describing here is in theory what PERL_USE_SAFE_PUTENV
Nah, not quite, but whoever created the original semantics for putenv() Rasmus Rasmus.Tamstorf@disney.com "A problem worthy of attack, |
Bruh its been 21 years, can someone fix this please lmao |
@Michael1095 how do you suggest we fix it? |
For starters, $0 scribbles on envp sometimes in order to lengthen it. https://github.com/Perl/perl5/blob/blead/perl.c#L1801 |
4efc5df seems to have added this comment after this ticket was opened: /* only the parent thread can clobber the process environment */ |
The problem here (restated) appears to be C handing to Perl which manipulates %ENV and then wants to hand it back to C so more stuff can be done. It also appears to be re-using the memory provided to it by C to store the env vars. Perl doesn't understand that when it hands back, it needs to sync back %ENV into the C strings. I SUSPECT that given the changes to SHEKs and COW over the years, this problem may be very different in a modern Perl these days. Given the age of this ticket and lacking any practical examples to reproduce this issue or access to the referred to patch, I am closing this. If someone has more details or a recent example, please open a new ticket. Thanks! |
As also stated in the stdlib documentation, setenv() is a bit of a dangerous interface and can cause a lot of headaches. For instance, perl before version 5.38 (at the time of writing, debian stable (bookworm) uses version 5.36) manipulates the `environ` pointer directly. When calling rust (or any other language) code from perl via bindings, calling `setenv` easily leads to crashes[2]. In perl 5.38 this was fixed [1] and perl should itself also stick to using `setenv`. This improves the situation a lot and leaves only the threading issue we cannot solve here. This commit allows the perl code to preset the environment variables to avoid at least this instance of setenv causing crashes. See-also: Perl/perl5#339 See-also: Perl/perl5#859 See-also: [1] Perl/perl5@916a038 See-also: [2] https://bugzilla.proxmox.com/show_bug.cgi?id=4979 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Migrated from rt.perl.org#1170 (status was 'open')
Searchable as RT1170$
The text was updated successfully, but these errors were encountered: