Avoid calling setenv with identical previous contents. #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, callingsetenv
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
Note: ideally we could avoid the 2nd query to the env vars, but that would require a breaking change to
ProbeResult
to include where the values came from.