Skip to content

Commit 502e856

Browse files
authored
Merge pull request #1853 from dscho/fix-gc-segfault
Fix occasional segmentation fault in `git gc`
2 parents ba593a7 + 843931b commit 502e856

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

builtin/pack-objects.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,6 @@ static void init_threaded_search(void)
22992299
pthread_mutex_init(&cache_mutex, NULL);
23002300
pthread_mutex_init(&progress_mutex, NULL);
23012301
pthread_cond_init(&progress_cond, NULL);
2302-
pthread_mutex_init(&to_pack.lock, NULL);
23032302
old_try_to_free_routine = set_try_to_free_routine(try_to_free_from_threads);
23042303
}
23052304

pack-objects.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ void prepare_packing_data(struct packing_data *pdata)
148148
1U << OE_SIZE_BITS);
149149
pdata->oe_delta_size_limit = git_env_ulong("GIT_TEST_OE_DELTA_SIZE",
150150
1UL << OE_DELTA_SIZE_BITS);
151+
#ifndef NO_PTHREADS
152+
pthread_mutex_init(&pdata->lock, NULL);
153+
#endif
151154
}
152155

153156
struct object_entry *packlist_alloc(struct packing_data *pdata,

pack-objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,
356356
return e->delta_size_;
357357

358358
/*
359-
* pack->detla_size[] can't be NULL because oe_set_delta_size()
359+
* pack->delta_size[] can't be NULL because oe_set_delta_size()
360360
* must have been called when a new delta is saved with
361361
* oe_set_delta().
362362
* If oe_delta() returns NULL (i.e. default state, which means

t/t5319-pack-large-objects.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2018 Johannes Schindelin
4+
#
5+
6+
test_description='git pack-object with "large" deltas
7+
8+
'
9+
. ./test-lib.sh
10+
. "$TEST_DIRECTORY"/lib-pack.sh
11+
12+
# Two similar-ish objects that we have computed deltas between.
13+
A=01d7713666f4de822776c7622c10f1b07de280dc
14+
B=e68fe8129b546b101aee9510c5328e7f21ca1d18
15+
16+
test_expect_success 'setup' '
17+
clear_packs &&
18+
{
19+
pack_header 2 &&
20+
pack_obj $A $B &&
21+
pack_obj $B
22+
} >ab.pack &&
23+
pack_trailer ab.pack &&
24+
git index-pack --stdin <ab.pack
25+
'
26+
27+
test_expect_success 'repack large deltas' '
28+
printf "%s\\n" $A $B |
29+
GIT_TEST_OE_DELTA_SIZE=2 git pack-objects tmp-pack
30+
'
31+
32+
test_done

0 commit comments

Comments
 (0)