Logic error in GetEnv() #15364
Labels
area-Windows
Windows-specific issues and feature requests
help wanted
Someone outside the Bazel team could own this
P2
We'll consider working on this in future. (Assignee optional)
team-OSS
Issues for the Bazel OSS team: installation, release processBazel packaging, website
type: bug
Description of the bug:
If you force Bazel to use an empty PATH environment variable (e.g.
build --action_env=PATH=
in .bazelrc) and run tests, you will get an error:Looking at the implementation, it uses GetEnvironmentVariableW, which has following possible results:
The bug is in the handling of a zero returnvalue, which can mean three things:
GetLastError() == ERROR_ENVVAR_NOT_FOUND
.GetLastError() == 0
. This is the case that is not handled correctly in the code.GetLastError()
gives you further info on the error.Suggested fix for the condition:
...plus of course extending the existing unit tests to permanently ban that bug from the codebase.
Cheers & happy hacking!
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
As mentioned above, it's the PATH setting plus running tests (C++ or C test code based on Google Test). I haven't extracted a proper minimal example yet. I would like to avoid that but I can, if above info doesn't suffice.
Which operating system are you running Bazel on?
MS Windows
What is the output of
bazel info release
?5.1.1
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.n/a
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No similar issues were reported yet.
Any other information, logs, or outputs that you want to share?
There is a workaround: Don't use an empty PATH. In order to get an effectively empty path, you can set it to
;
(single semicolon) instead.The text was updated successfully, but these errors were encountered: