|Anonymous | Login | Signup for a new account||2015-07-06 17:42 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0004499||OCaml||OCaml windows||public||2008-02-05 18:10||2015-06-15 22:42|
|Target Version||after-4.02.2||Fixed in Version|
|Summary||0004499: Changes to the environment are invisible to Sys.getenv|
|Description||Windows has functions like SetEnvironmentVariable/GetEnvironmentVariable to access the process environment. The MS C runtime library also has getenv/putenv functions, but they operate on a snapshot of the environment taken when the process started. putenv also push modifications to the real environment through SetEnvironmentVariable.|
So, if we mix in a single process OCaml code and other native code that set environment variables directly (from .Net, we only have SetEnvironmentVariable, not putenv), these changes are not seen from OCaml, which uses getenv.
A fix would be to use the "native" win32 functions for OCaml (not only for implementing Sys.getenv, but also for all the calls to getenv in the runtime system; and some care is needed for execve).
(At LexiFi, we use a temporary solution: we have a function to "refresh" the local copy of the environment in the libc by fetching all the real environment variable and putenv'ing them.)
|Tags||No tags attached.|
I could easily argue that this is a bug in the getenv of the MS C runtime library.
> I could easily argue that this is a bug in the getenv of the MS C runtime library.
Probably, but it's easier (for us) to work-around the problem on the OCaml side than to convince Microsoft to fix their C runtime. As long as the effort remains reasonable, I think it's good to provide a coherent semantics between all the supported OCaml ports, even if this requires to work around bugs created by third parties.
The right solution is probably to define our own functions sys_getenv and sys_putenv once with system-dependent code, and then use them everywhere.
In fact, from your description it seems we only need to redefine getenv.
Pushing this for later, as I don't see the issue fixed in time for 4.01.
|What would be the functions involved? From a very very quick glance at MSDN, I don't see links to similar functions.|
|2008-02-05 18:10||frisch||New Issue|
|2008-02-19 14:49||doligez||Note Added: 0004452|
|2008-02-19 14:49||doligez||Status||new => acknowledged|
|2012-06-20 11:20||frisch||Category||OCaml general => OCaml windows|
|2012-06-20 11:25||frisch||Note Added: 0007582|
|2012-07-11 15:58||doligez||Target Version||=> 4.01.0+dev|
|2012-07-31 13:37||doligez||Target Version||4.01.0+dev => 4.00.1+dev|
|2012-09-15 11:57||doligez||Note Added: 0008078|
|2012-09-15 11:57||doligez||Target Version||4.00.1+dev => 4.00.2+dev|
|2013-07-09 16:09||doligez||Target Version||4.00.2+dev => 4.01.0+dev|
|2013-07-29 16:56||xleroy||Note Added: 0009989|
|2013-07-29 16:56||xleroy||Target Version||4.01.0+dev => 4.01.1+dev|
|2014-05-25 20:20||doligez||Target Version||4.01.1+dev => 4.02.0+dev|
|2014-07-30 23:21||doligez||Target Version||4.02.0+dev => 4.02.1+dev|
|2014-09-04 00:25||doligez||Target Version||4.02.1+dev => undecided|
|2014-09-26 16:53||doligez||Target Version||undecided => 4.02.2+dev / +rc1|
|2015-03-18 17:52||frisch||Target Version||4.02.2+dev / +rc1 => after-4.02.2|
|2015-06-15 10:27||frisch||Relationship added||related to 0006903|
|2015-06-15 22:42||adrien||Note Added: 0014086|
|Copyright © 2000 - 2011 MantisBT Group|