@matheusbsbs / matheus-bagliano / commits / ca9d60f246
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 29, 2024 at 23:26 UTC ca9d60f2460c296b32b3da97eb953bbc4d292197
1 file changed -2
builtin/index-pack.c
-2
@@ -1336,7 +1336,6 @@ static void resolve_deltas(struct pack_idx_option *opts)
1336 base_cache_limit = opts->delta_base_cache_limit * nr_threads;
1337 if (nr_threads > 1 || getenv("GIT_FORCE_THREADS")) {
1338 init_thread();
1339 - work_lock();
1339 for (i = 0; i < nr_threads; i++) {
1340 int ret = pthread_create(&thread_data[i].thread, NULL,
1341 threaded_second_pass, thread_data + i);
@@ -1344,7 +1343,6 @@ static void resolve_deltas(struct pack_idx_option *opts)
1343 die(_("unable to create thread: %s"),
1344 strerror(ret));
1345 }
1347 - work_unlock();
1346 for (i = 0; i < nr_threads; i++)
1347 pthread_join(thread_data[i].thread, NULL);
1348 cleanup_thread();