-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_wputenv() memory semantics #1425
Comments
I am not understanding your issue. _WCRTLINK extern int _wputenv( const wchar_t *__string ); // MS specific Any of this is not covered by C standard We can discuse compatibility with POSIX, but OW use historicaly old MS syntax and it doesn't case issue with POSIX code. If we are talking about clearenv then we talk about following class of functions. Only getenv is covered by C standard and POSIX. setenv and unsetenv is POSIX standard clearenv is not covered by any standard. Please specify more clearly what problem is. |
Take into account there are a few CRTL configuration parameters (in bld/lib_misc/variety.h) which handle environment processing code.
|
Main issue is inconsistent memory semantics with the Windows ucrt for _[w]putenv(), assumed by 3rd libraries, Can you review the realloc logic within waddenv, reference, should
|
Sorry our CRTL is not replacement of Microsoft UCRT. You must specify platform and function and problem, because some implementations can be very OS specific. If you have a fix for your problem then you can create and submit PR. |
To use _RWD_env_mask, it is flag array which flag environment entries globaly it has nothing to do with wide version of environment. |
Shall continue investigating, correct i was referencing win32 semantics. FYI on reviewing the original MSVC 6/VC98 (1998) runtime, |
But there is no semantic difference in wputenv(), OW and MS use const char pointer for item that owner is always caller. |
OWC _wputev() only references the passed value, whereas the original msvc win32 implementation copies. Output from simple test application, yet owc is undefined:
Source:
|
It is implementation bug and need to fix it. |
The windows UCRT copies the buffer that's passed to _[w]putenv, whereas OW20 assumes the same semantics as putenv, being ownership of the storage.
Interfaces utilize const interfaces, compared to putenv(), one could imply non ownership.
One example usage, see glib
g_setenv()
assumes copy semantics g_setenv / G_OS_WIN32Another example of this assumption python issue 39406.
UCRT Source Reference, SDK-19041:
C:/Program Files (x86)/Windows Kits/10/Source/10.0.19041.0/ucrt/env/putenv.cpp
OWC20 clearenv() may release the assigned storage clearenv, whereas OWC19 wont. Updates assume ownership and realloc addenv/waddenv. Both can result in runtime errors.
Note:
Believe the realloc selection ignore the WIDECHAR condition as it references
_RWD_env_mask
unconditionally.The text was updated successfully, but these errors were encountered: