From: Jeff King Date: Mon, 30 Dec 2024 04:26:10 +0000 (-0500) Subject: Revert "index-pack: spawn threads atomically" X-Git-Tag: v2.48.0-rc2~8^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca9d60f2460c296b32b3da97eb953bbc4d292197;p=thirdparty%2Fgit.git Revert "index-pack: spawn threads atomically" This reverts commit 993d38a0669a8056d496797516e743e26b6b8b54. That commit was trying to solve a race between LSan setting up the threads stack and another thread calling exit(), by making sure that all pthread_create() calls have finished before doing any work that might trigger the exit(). But that isn't sufficient. The setup code actually runs in the individual threads themselves, not in the spawning thread's call to pthread_create(). So while it may have improved the race a bit, you can still trigger it pretty quickly with: make SANITIZE=leak cd t ./t5309-pack-delta-cycles.sh --stress Let's back out that failed attempt so we can try again. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/index-pack.c b/builtin/index-pack.c index d773809c4c..0b62b2589f 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1336,7 +1336,6 @@ static void resolve_deltas(struct pack_idx_option *opts) base_cache_limit = opts->delta_base_cache_limit * nr_threads; if (nr_threads > 1 || getenv("GIT_FORCE_THREADS")) { init_thread(); - work_lock(); for (i = 0; i < nr_threads; i++) { int ret = pthread_create(&thread_data[i].thread, NULL, threaded_second_pass, thread_data + i); @@ -1344,7 +1343,6 @@ static void resolve_deltas(struct pack_idx_option *opts) die(_("unable to create thread: %s"), strerror(ret)); } - work_unlock(); for (i = 0; i < nr_threads; i++) pthread_join(thread_data[i].thread, NULL); cleanup_thread();