Comments (17)
Hmm. We probably could side-step this entire issue by ripping out these lines from run_post_command_hook()
:
lock = getenv("COMMAND_HOOK_LOCK");
if (!lock || strcmp(lock, "true"))
return 0;
I do not see why they are needed: The preceding lines verify that run_post_hook
is set to something non-zero, which is only the case after the environment variable COMMAND_HOOK_LOCK
is defined to true
anyway, and nothing in the same process seems to be able to override that, and child processes cannot override the current process' environment, either.
So I do not see why that getenv()
call is needed at all, it is redundant, I think.
What do you think @jeffhostetler?
from git.
I don't understand how this "lock" is corrdinated with other concurrent Git processes
Well, if it wanted to talk to concurrent processes, then environment variables are the wrong way to do it, as they do not influence each other across processes (except child processes that inherit the parents' environment variables on startup).
from git.
Making notes here while I crawl back thru the stack trace...
git.exe
is inrun_post_command_hook()
and looking upCOMMAND_HOOK_LOCK
environment variable.- The
mingw_getenv()
code is allocating a buffer to receiver the envvar. - The
compat/mimalloc
code being used instead of the LIBC malloc routines. - The
_mi_malloc_generic()
does not believe that the heap is initialized and tries to initialize it.- This is dubious, since we are about to shutdown and should have used lots of memory already.
- The
_mi_thread_init()
code initializes (er, ?re-initializes?) the process/thread state and calls_mi_heap_init()
. _mi_heap_init()
does not think it is the main thread and needs to generate random keys for thread-local-data.mi_random_init_ex()
callsos_random_buf()
which (depending on some#ifdef
s) calls eitherRtlGenRandom()
orLoadLibrary()
intobcrypt.dll
.
from git.
Adding a little more context (which I started writing before @jeffhostetler posted an answer):
git.exe!mi_random_init_ex() Line 325 C++ git.exe!_mi_heap_init() Line 282 C++ git.exe!mi_thread_init() Line 437 C++ git.exe!_mi_malloc_generic() Line 423 C++
This is in the mimalloc code that is vendored into Git for Windows since v2.38.0.
from git.
https://github.com/microsoft/mimalloc/issues?q=is%3Aissue+is%3Aopen+bcryptprimitives lists some interesting tickets, looking now.
from git.
msvcrt.dll!doexit() Unknown
Oh wait! I think that's it. microsoft/mimalloc#521 (comment) suggests that there may be issues initializing the bcrypt routines while exiting.
from git.
Yeah, I was wondering about how much work we were doing in an atexit() callback.
from git.
Yeah, it's weird. We are "holding" the lock in env block of the current process so that child processes can inherit it?? So that that they don't try to take the lock maybe?? And the guard on run_post_hook
guarantees that the process that took the "lock" is the one that releases it, so we don't have to worry about child processes prematurely/incorrectly releasing it.
However, I don't understand how this "lock" is corrdinated with other concurrent Git processes, but we don't have to solve that today....
from git.
IIRC, the gvfs mount daemon/service blocks the pre-command hook task until it is available. so they handle the concurrency thing inside the daemon. the code here is necessary to prevent child process from trying the lock and getting blocked.
I had forgotten about that.
from git.
I think the post-command hook check is to prevent endless recursion because the hook might execute Git commands. Removing it is unlikely to be a solution.
from git.
At startup (on locally built version of git.exe):
crt/gccmain.c : __do_global_ctors()
calls intomi_process_init()
andmi_process_load()
andmi_heap_main_init()
which calls_mi_random_init_weak()
at line init.c:172.- So we do not initialize bcrypt.dll at startup (we force "use_weak" while the OS handles the rest of the process startup stuff and use internal code to generate the random seed data).
_mi_random_init_ex()
is not called again (well, in my attempts to repro it) until I forced it in anatexit()
handler function.
See #579 for more discussion.
from git.
from git.
from git.
@jeffhostetler I think the only thing left to do is to promote v2.40.1.vfs.0.1
as a full release, and then we can close this, right? When do you want to do that?
from git.
yeah.
from git.
button pushed.
from git.
thank you for fixing this!
from git.
Related Issues (20)
- Apple Silicon/macOS ARM build for microsoft/git
- Add Windows ARM64 native release for microsoft/git HOT 1
- Repeated Indexing Outputs/Resolving Deltas output when pulling after upgrading to 2.40.1.vfs.0.2 HOT 4
- Redirecting stdout causes the program to stop for 40 seconds HOT 1
- Git maintenance scheduling impacting scalability of large repos. HOT 1
- microsoft.git not respecting --disable-interactivity flag in winget HOT 5
- git-maintenance doesn't work on WSL HOT 19
- Crashing during sparse-checkout operations HOT 5
- Google.com
- unable to normalize alternate object path HOT 2
- git fetch --depth 1 is not working HOT 4
- How to slim down .scalarCache? HOT 8
- git pull takes a long time
- microsoft-git cask returns a 404 in the latest version of Git
- `git for-each-repo` stops on non-existent repo (Windows?) HOT 3
- git-maintenance doesn't work with git-credential-manager & pass HOT 4
- Steps when a scalar repo becomes corrupted
- Broken link in README
- git commit take a long time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git.