[crac] RFR: Environment vars propagation into restored process
Dan Heidinga
heidinga at openjdk.org
Fri Sep 30 14:39:00 UTC 2022
On Thu, 29 Sep 2022 15:38:52 GMT, Roman Marchenko <duke 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?
-------------
PR: https://git.openjdk.org/crac/pull/30
More information about the crac-dev
mailing list