[crac] RFR: Environment vars propagation into restored process

Roman Marchenko duke at openjdk.org
Mon Oct 3 14:26:39 UTC 2022


On Fri, 30 Sep 2022 14:35:29 GMT, Dan Heidinga <heidinga at openjdk.org> wrote:

>> This PR provides functionality to propagate actual environment variables to a restored process, as well as the test for this functionality.
>> 
>> Env propagation is done in few steps:
>> - Store the actual environment before restoring
>> - After restoring, replace the restored `environ` with a new one.
>> - On `afterRestore` event, propagate the new environment into a restored process via `ProcessEnvironment`.
>
> One concern with this approach - it means that environment variables will change values after a restore.
> 
> It seems odd to say this is a concern when it's the intended behaviour of this PR but it is a concern.  Users typically cache environment variables in static fields or use them to make a one time decision.  They don't expect them (at least at the Java layer) to change value throughout a run of the same process.
> 
> This change means two reads of the same env var can give different results at different times which may put unsuspecting applications into inconsistent states if two locations read the env var before vs after a restore.  That's going to be a hard to debug issue.
> 
> The VM may also read env vars and bind tightly to the value.  Native code after a restore will still have the original env while java code the modified env.  Do we foresee any issues there?

@DanHeidinga 
Hi, 
You're right in your concerns. Indeed the suggested enhancement changes the usual workflow, so users may be confused. 
That is why we expect users to explicitly adapt their applications in accordance with the behaviour and make sure it works, otherwise there is no guarantee the application run with CRaC is successful.

-------------

PR: https://git.openjdk.org/crac/pull/30


More information about the crac-dev mailing list