1
0
mirror of https://github.com/git/git.git synced 2025-02-06 10:03:06 +00:00

Revert barrier-based LSan threading race workaround

The extra "barrier" approach was too much code whose sole purpose
was to work around a race that is not even ours (i.e. in LSan's
teardown code).

In preparation for queuing a solution taking a much-less-invasive
approach, let's revert them.
This commit is contained in:
Junio C Hamano 2025-01-01 14:13:01 -08:00
parent 7a8d9efc26
commit fc89d14c63
5 changed files with 0 additions and 39 deletions

View File

@ -141,10 +141,6 @@ include shared.mak
#
# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
#
# Define THREAD_BARRIER_PTHREAD if your system has pthread_barrier_t. Barrier
# support is optional and is only helpful when building with SANITIZE=leak, as
# it is used to eliminate some races in the leak-checker.
#
# Define NO_PREAD if you have a problem with pread() system call (e.g.
# cygwin1.dll before v1.5.22).
#
@ -2083,9 +2079,6 @@ ifdef NO_PTHREADS
else
BASIC_CFLAGS += $(PTHREAD_CFLAGS)
EXTLIBS += $(PTHREAD_LIBS)
ifdef THREAD_BARRIER_PTHREAD
BASIC_CFLAGS += -DTHREAD_BARRIER_PTHREAD
endif
endif
ifdef HAVE_PATHS_H

View File

@ -101,9 +101,6 @@ static pthread_cond_t cond_write;
/* Signalled when we are finished with everything. */
static pthread_cond_t cond_result;
/* Synchronize the start of all threads */
static maybe_thread_barrier_t start_barrier;
static int skip_first_line;
static void add_work(struct grep_opt *opt, struct grep_source *gs)
@ -201,8 +198,6 @@ static void *run(void *arg)
int hit = 0;
struct grep_opt *opt = arg;
maybe_thread_barrier_wait(&start_barrier);
while (1) {
struct work_item *w = get_work();
if (!w)
@ -234,7 +229,6 @@ static void start_threads(struct grep_opt *opt)
pthread_cond_init(&cond_add, NULL);
pthread_cond_init(&cond_write, NULL);
pthread_cond_init(&cond_result, NULL);
maybe_thread_barrier_init(&start_barrier, NULL, num_threads + 1);
grep_use_locks = 1;
enable_obj_read_lock();
@ -254,7 +248,6 @@ static void start_threads(struct grep_opt *opt)
die(_("grep: failed to create thread: %s"),
strerror(err));
}
maybe_thread_barrier_wait(&start_barrier);
}
static int wait_all(void)
@ -291,7 +284,6 @@ static int wait_all(void)
pthread_cond_destroy(&cond_add);
pthread_cond_destroy(&cond_write);
pthread_cond_destroy(&cond_result);
maybe_thread_barrier_destroy(&start_barrier);
grep_use_locks = 0;
disable_obj_read_lock();

View File

@ -185,8 +185,6 @@ static pthread_mutex_t deepest_delta_mutex;
static pthread_key_t key;
static maybe_thread_barrier_t start_barrier;
static inline void lock_mutex(pthread_mutex_t *mutex)
{
if (threads_active)
@ -211,7 +209,6 @@ static void init_thread(void)
if (show_stat)
pthread_mutex_init(&deepest_delta_mutex, NULL);
pthread_key_create(&key, NULL);
maybe_thread_barrier_init(&start_barrier, NULL, nr_threads);
CALLOC_ARRAY(thread_data, nr_threads);
for (i = 0; i < nr_threads; i++) {
thread_data[i].pack_fd = xopen(curr_pack, O_RDONLY);
@ -234,7 +231,6 @@ static void cleanup_thread(void)
for (i = 0; i < nr_threads; i++)
close(thread_data[i].pack_fd);
pthread_key_delete(key);
maybe_thread_barrier_destroy(&start_barrier);
free(thread_data);
}
@ -1104,8 +1100,6 @@ static int compare_ref_delta_entry(const void *a, const void *b)
static void *threaded_second_pass(void *data)
{
if (threads_active)
maybe_thread_barrier_wait(&start_barrier);
if (data)
set_thread_data(data);
for (;;) {

View File

@ -385,7 +385,6 @@ linux-musl)
;;
linux-leaks|linux-reftable-leaks)
export SANITIZE=leak
export THREAD_BARRIER_PTHREAD=1
;;
linux-asan-ubsan)
export SANITIZE=address,undefined

View File

@ -53,22 +53,5 @@ int dummy_pthread_init(void *);
int online_cpus(void);
int init_recursive_mutex(pthread_mutex_t*);
#ifdef THREAD_BARRIER_PTHREAD
#define maybe_thread_barrier_t pthread_barrier_t
#define maybe_thread_barrier_init pthread_barrier_init
#define maybe_thread_barrier_wait pthread_barrier_wait
#define maybe_thread_barrier_destroy pthread_barrier_destroy
#else
#define maybe_thread_barrier_t int
static inline int maybe_thread_barrier_init(maybe_thread_barrier_t *b UNUSED,
void *attr UNUSED,
unsigned nr UNUSED)
{
errno = ENOSYS;
return -1;
}
#define maybe_thread_barrier_wait(barrier)
#define maybe_thread_barrier_destroy(barrier)
#endif
#endif /* THREAD_COMPAT_H */