-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
WIP: Address getenv() issues #2019
base: main
Are you sure you want to change the base?
Commits on Jan 17, 2019
-
fixup! tests: include detailed trace logs with --write-junit-xml upon…
… failure The `cut -c` approach is *per line*, not *per file* as I had thought. So it does not work... Signed-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for cc7f43e - Browse repository at this point
Copy the full SHA cc7f43eView commit details -
DEBUG: invalidate getenv() calls when the next one is called
This is a crude, and incomplete, way to diagnose getenv() issues where the return value is not used transiently. Signed-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for acd1aae - Browse repository at this point
Copy the full SHA acd1aaeView commit details -
DEBUG2: help diagnosing issues
Signed-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 48a2b7d - Browse repository at this point
Copy the full SHA 48a2b7dView commit details -
WORK-AROUND: force
fmt_ident(...)
to succeedSigned-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5a6c20a - Browse repository at this point
Copy the full SHA 5a6c20aView commit details -
Signed-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e388cfa - Browse repository at this point
Copy the full SHA e388cfaView commit details -
TODO: left-over bit from env conversion
Signed-off-by: Johannes Schindelin <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ce83ddc - Browse repository at this point
Copy the full SHA ce83ddcView commit details -
get_super_prefix(): copy getenv() result
The return value of getenv() is not guaranteed to remain valid across multiple calls (nor across calls to setenv()). Since this function caches the result for the length of the program, we must make a copy to ensure that it is still valid when we need it. Reported-by: Yngve N. Pettersen <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0bf3c96 - Browse repository at this point
Copy the full SHA 0bf3c96View commit details -
commit: copy saved getenv() result
We save the result of $GIT_INDEX_FILE so that we can restore it after setting it to a new value and running add--interactive. However, the pointer returned by getenv() is not guaranteed to be valid after calling setenv(). This _usually_ works fine, but can fail if libc needs to reallocate the environment block during the setenv(). Let's just duplicate the string, so we know that it remains valid. In the long run it may be more robust to teach interactive_add() to take a set of environment variables to pass along to run-command when it execs add--interactive. And then we would not have to do this save/restore dance at all. But this is an easy fix in the meantime. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ce2c4c2 - Browse repository at this point
Copy the full SHA ce2c4c2View commit details -
config: make a copy of $GIT_CONFIG string
cmd_config() points our source filename pointer at the return value of getenv(), but that value may be invalidated by further calls to environment functions. Let's copy it to make sure it remains valid. We don't need to bother freeing it, as it remains part of the whole-process global state until we exit. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 43652dc - Browse repository at this point
Copy the full SHA 43652dcView commit details -
init: make a copy of $GIT_DIR string
We pass the result of getenv("GIT_DIR") to init_db() and assume that the string remains valid. But that's not guaranteed across calls to setenv() or even getenv(), although it often works in practice. Let's make a copy of the string so that we follow the rules. Note that we need to mark it with UNLEAK(), since the value persists until the end of program (but we have no opportunity to free it). This patch also handles $GIT_WORK_TREE the same way. It actually doesn't have as long a lifetime and is probably fine, but it's simpler to just treat the two side-by-side variables the same. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5bb5a8b - Browse repository at this point
Copy the full SHA 5bb5a8bView commit details -
merge-recursive: copy $GITHEAD strings
If $GITHEAD_1234abcd is set in the environment, we use its value as a "better branch name" in generating conflict markers. However, we pick these better names early in the process, and the return value from getenv() is not guaranteed to stay valid. Let's make a copy of the returned string. And to make memory management easier, let's just always return an allocated string from better_branch_name(), so we know that it must always be freed. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 69cbeaa - Browse repository at this point
Copy the full SHA 69cbeaaView commit details -
builtin_diff(): read $GIT_DIFF_OPTS closer to use
The value returned by getenv() is not guaranteed to remain valid across other environment function calls. But in between our call and using the value, we run fill_textconv(), which may do quite a bit of work, including spawning sub-processes. We can make this safer by calling getenv() right before we actually look at its value. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for cb62289 - Browse repository at this point
Copy the full SHA cb62289View commit details -
Configuration menu - View commit details
-
Copy full SHA for 162ee3f - Browse repository at this point
Copy the full SHA 162ee3fView commit details