git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [regression] Newer gits cannot clone any remote repos

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Nov 15, 2012, 18:55 UTC
Message-ID
<50A53AAE.7080406@ramsay1.demon.co.uk>
In-Reply-To
<CACYvZ7jMC5xw4LxiuG5m+=grpQEg+wZb_7BaU4Xn-r7ix=S-bw@mail.gmail.com>
Douglas Mencken wrote:
Show 17 quoted lines
>>  Could you try re-building git with the
>> NO_THREAD_SAFE_PREAD build variable set?
> 
> Yeah! It works!!!
> 
> --- evil/Makefile
> +++ good/Makefile
> @@ -957,6 +957,7 @@
>  	HAVE_PATHS_H = YesPlease
>  	LIBC_CONTAINS_LIBINTL = YesPlease
>  	HAVE_DEV_TTY = YesPlease
> +	NO_THREAD_SAFE_PREAD = YesPlease
>  endif
>  ifeq ($(uname_S),GNU/kFreeBSD)
>  	NO_STRLCPY = YesPlease
> 
> With this, I do have correctly working git clone.
OK, good.

You didn't mention which platform you are on; from the above Makefile hunk, however, I can deduce that you are on *some* version of Linux.

Hmm, it doesn't seem too likely that your pread() is thread-unsafe (possible, just unlikely), so it could be a more fundamental problem with the threaded index-pack code (ie commit b8a2486f1 et. seq.).

However, as a first step could you try running the test program (given below) on your system to determine if your pread() is thread-safe or not. (gcc -I. -o test-pread test-pread.c; ./test-pread)

Also, what is the output of "uname -a".

ATB, Ramsay Jones

-- >8 -- #include "git-compat-util.h" #include "thread-utils.h"

#define DATA_FILE "junk.data" #define MAX_DATA 256 * 1024 #define NUM_THREADS 3 #define TRIALS 500000

struct thread_data {
	pthread_t t;
	int fd;
	int cnt;
	int fails;
	unsigned long n;
};
static struct thread_data t[NUM_THREADS+1];
int create_data_file(void)
{
	int i, fd = open(DATA_FILE, O_CREAT | O_TRUNC | O_WRONLY, 0600);
	if (fd < 0)
		return -1;
	for (i = 0; i < MAX_DATA; i++)
		if (write(fd, &i, sizeof(int)) < 0) {
			close(fd);
			unlink(DATA_FILE);
			return -1;
		}
	close(fd);
	return 0;
}
void *read_thread(void *data)
{
	struct thread_data *d = (struct thread_data *)data;
	int i, j, rd;
	for (i = 0; i < TRIALS; i += MAX_DATA) {
		for (j = 0; j < MAX_DATA; j++) {
			ssize_t sz = read(d->fd, &rd, sizeof(int));
			if (sz < 0 || rd != j)
				d->fails++;
			d->cnt++;
		}
		lseek(d->fd, 0, SEEK_SET);
	}
	return NULL;
}
void *pread_thread(void *data)
{
	struct thread_data *d = (struct thread_data *)data;
	int i, j, rd;
	for (i = 0; i < TRIALS; i++) {
		ssize_t sz;
		d->n = d->n * 1103515245 + 12345;
		j = d->n % MAX_DATA;
		sz = pread(d->fd, &rd, sizeof(int), j * sizeof(int));
		if (sz < 0 || rd != j)
			d->fails++;
		d->cnt++;
	}
	return NULL;
}
int main(int argc, char *argv[])
{
	int fd, i;
	if (create_data_file() < 0) {
		printf("can't create data file\n");
		return 1;
	}
	if ((fd = open(DATA_FILE, O_RDONLY)) < 0) {
		printf("can't open data file\n");
		unlink(DATA_FILE);
		return 1;
	}
	for (i = 0; i < NUM_THREADS+1; i++) {
		int ret;
		t[i].fd = fd;
		t[i].cnt = 0;
		t[i].fails = 0;
		t[i].n = i * 16381;
		ret = pthread_create(&t[i].t, NULL,
				(i == 0) ? read_thread : pread_thread,
				&t[i]);
		if (ret) {
			printf("can't create thread %d (%s)\n", i, strerror(ret));
			unlink(DATA_FILE);
			return 1;
		}
	}
	for (i = 0; i < NUM_THREADS+1; i++)
		pthread_join(t[i].t, NULL);
	close(fd);
	for (i = 0; i < NUM_THREADS+1; i++)
		printf("%2d: trials %d, failed %d\n", i, t[i].cnt, t[i].fails);
	unlink(DATA_FILE);
	return 0;
}
Previous: Nguyen Thai Ngoc DuyNext: Torsten Bögershausen
Message 8 of 17 in “[regression] Newer gits cannot clone any remote repos”
  1. Douglas MenckenNov 12, 2012
  2. KevinNov 12, 2012
  3. Douglas MenckenNov 12, 2012
  4. Ramsay JonesNov 13, 2012
  5. Douglas MenckenNov 13, 2012
  6. Douglas MenckenNov 13, 2012
  7. Nguyen Thai Ngoc DuyNov 15, 2012
  8. Ramsay JonesNov 15, 2012
  9. Torsten BögershausenNov 13, 2012
  10. Andreas SchwabNov 13, 2012
  11. Douglas MenckenNov 14, 2012
  12. Andreas SchwabNov 14, 2012
  13. Douglas MenckenNov 14, 2012
  14. Andreas SchwabNov 14, 2012
  15. Ramsay JonesNov 15, 2012
  16. Douglas MenckenNov 21, 2012
  17. Douglas MenckenNov 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.