Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix usage of environment in PAL #3140

Merged
merged 6 commits into from
Feb 27, 2016

Conversation

adityamandaleeka
Copy link
Member

While investigating #1664, I noticed that the code we had for dealing with the environment was doing some dangerous things, and could be very problematic in certain cases (for instance, if user code PInvoked into a POSIX environment function).

This change makes it so we read the contents of the environment once on startup, copy them to our own internal representation, and operate on that internal representation from that point forward.

See this comment for more details.

@stephentoub @jkotas

@adityamandaleeka
Copy link
Member Author

Oh, and this fixes #1664 😄

@jkotas
Copy link
Member

jkotas commented Feb 11, 2016

@janvorli Could you please take a look? I am travelling till mid next week...

// buffer anyway, so just stay in the critical section until then.
InternalEnterCriticalSection(pthrCurrent, &gcsEnvironment);
enteredCritSec = true;

Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that instead of tracking the entering of critical section, it would be cleaner to move the string copying and critical section leaving here. This is the only code path that actually generates non-null value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, good idea.

@stephentoub
Copy link
Member

@adityamandaleeka, thanks... if you haven't already done so, could you run the System.Runtime.Extensions tests from corefx with your changes?

@adityamandaleeka adityamandaleeka force-pushed the env_pal branch 3 times, most recently from 82472d0 to d475f00 Compare February 17, 2016 03:32
@janvorli
Copy link
Member

LGTM

@adityamandaleeka
Copy link
Member Author

Not sure what triggered that CI run today, but it seems to have failed due to infrastructure issues. It was fine before.

@dotnet-bot retest this please

@adityamandaleeka
Copy link
Member Author

@stephentoub I verified that all 543 of the tests in System.Runtime.Extensions.Tests passed with my coreclr changes.

@stephentoub
Copy link
Member

Thanks, @adityamandaleeka.


if (checkAlignmentSettings)
{
InternalFree(checkAlignmentSettings);

Choose a reason for hiding this comment

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

Is it safe to free the value returned by getenv()?

@adityamandaleeka adityamandaleeka force-pushed the env_pal branch 2 times, most recently from 395bb39 to d694dfc Compare February 19, 2016 04:26
@sergiy-k
Copy link

LGTM

@adityamandaleeka
Copy link
Member Author

@dotnet-bot test this please

@adityamandaleeka
Copy link
Member Author

@dotnet-bot test this please

(requeuing this job per instructions from @mmitche)

@mmitche mmitche closed this Feb 25, 2016
@mmitche mmitche reopened this Feb 25, 2016
@adityamandaleeka
Copy link
Member Author

@dotnet-bot test OSX x64 Checked Build and Test

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants