Skip to content

Please update Vietnamese translation! #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed

Conversation

vnwildman
Copy link
Contributor

Please pull from my repository to add git translation for Vietnamese.

jiangxin and others added 20 commits May 3, 2012 18:41
Generate po/git.pot from v1.7.10.1-433-g34875f.

 * 273 new l10n messages at lines:
   41, 46, 55, 67, 74, 79, 89, 93, 97, 101, 106, 110, 142, 148, 155,
   162, 169, 176, 183, 190, 197, 204, 286, 290, 301, 308, 313, 318, 327,
   411, 416, 420, 425, 430, 952, 957, 962, 967, 972, 977, 982, 987, 992,
   997, 1007, 1012, 1016, 1021, 1026, 1031, 1036, 1041, 1047, 1052, ...

 * 15 removed l10n messages from lines:

   803, 821, 838, 843, 912, 1356, 1377, 1454, 1458, 1464, 1471, 1517,
   1819, 1824, 1898

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Generate po/git.pot from v1.7.10.2-548-g9de96:

 * 41 new l10n messages at lines:

   332, 337, 344, 349, 967, 1288, 1292, 1296, 1300, 1304, 1308, 1312,
   1316, 1320, 1324, 1328, 1332, 1336, 1340, 1344, 1348, 1352, 1356,
   1360, 1364, 1368, 1372, 1376, 1380, 1384, 1388, 1392, 1396, 4465,
   4469, 4473, 4477, 4481, 4485, 4489, 4493.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
@Krenair
Copy link

Krenair commented May 26, 2012

"Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements."

@vnwildman vnwildman closed this May 27, 2012
derrickstolee referenced this pull request in derrickstolee/git Oct 8, 2018
derrickstolee referenced this pull request in derrickstolee/git Nov 1, 2018
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 20, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 20, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 20, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 21, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 21, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 21, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 24, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 25, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 25, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 26, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 29, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Apr 30, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
phillipwood added a commit to phillipwood/git that referenced this pull request Jun 19, 2022
 test-results/t0010-racy-git.out...
 ------------------------------------------------------------------------
 Initialized empty Git repository in /__w/git/git/t/trash directory.t0010-racy-git/.git/
 =================================================================
 ==7972==ERROR: AddressSanitizer: invalid-pointer-pair: 0x6020000004f0 0x6020000004ef
     #0 0x7cfcbb in count_trailing_blank diff.c:621
     #1 0x7cfe73 in check_blank_at_eof diff.c:637
     #2 0x804cb9 in builtin_diff diff.c:3583
     #3 0x809494 in run_diff_cmd diff.c:4428
     #4 0x80ae96 in run_diff diff.c:4517
     #5 0x80ae96 in diff_flush_patch diff.c:5870
     git#6 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     #7 0x80cb6a in diff_flush diff.c:6552
     git#8 0x7c831f in run_diff_files diff-lib.c:265
     git#9 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#10 0x41e8c9 in run_builtin git.c:465
     git#11 0x41e8c9 in handle_builtin git.c:719
     git#12 0x41f9ac in run_argv git.c:786
     git#13 0x41f9ac in cmd_main git.c:917
     git#14 0x419515 in main common-main.c:56
     git#15 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#16 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#17 0x41b494 in _start (git+0x41b494)

 0x6020000004f0 is located 0 bytes inside of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 0x6020000004ef is located 1 bytes to the left of 7-byte region [0x6020000004f0,0x6020000004f7)
 allocated by thread T0 here:
     #0 0x7f8a847c291f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
     #1 0xc30972 in do_xmalloc wrapper.c:51
     #2 0xc30afd in do_xmallocz wrapper.c:85
     #3 0xc30afd in do_xmallocz wrapper.c:75
     #4 0xc30afd in xmallocz wrapper.c:93
     #5 0x97fbe1 in unpack_loose_rest object-file.c:1312
     git#6 0x98d70c in loose_object_info object-file.c:1479
     #7 0x98e270 in do_oid_object_info_extended object-file.c:1577
     git#8 0x98e9fe in oid_object_info_extended object-file.c:1639
     git#9 0x7f3204 in diff_populate_filespec diff.c:4100
     git#10 0x7f3ab9 in diff_filespec_is_binary diff.c:3329
     git#11 0x805ec6 in builtin_diff diff.c:3507
     git#12 0x809494 in run_diff_cmd diff.c:4428
     git#13 0x80ae96 in run_diff diff.c:4517
     git#14 0x80ae96 in diff_flush_patch diff.c:5870
     git#15 0x80cb6a in diff_flush_patch_all_file_pairs diff.c:6409
     git#16 0x80cb6a in diff_flush diff.c:6552
     git#17 0x7c831f in run_diff_files diff-lib.c:265
     git#18 0x4ac215 in cmd_diff_files builtin/diff-files.c:82
     git#19 0x41e8c9 in run_builtin git.c:465
     git#20 0x41e8c9 in handle_builtin git.c:719
     git#21 0x41f9ac in run_argv git.c:786
     git#22 0x41f9ac in cmd_main git.c:917
     git#23 0x419515 in main common-main.c:56
     git#24 0x7f8a83bad55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
     git#25 0x7f8a83bad60b in __libc_start_main_impl (/lib64/libc.so.6+0x2d60b)
     git#26 0x41b494 in _start (git+0x41b494)

 SUMMARY: AddressSanitizer: invalid-pointer-pair diff.c:621 in count_trailing_blank
 ==7972==ABORTING

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
avar added a commit to avar/git that referenced this pull request Jul 28, 2022
This fails with e.g. this t9350-fast-export.sh test, perhaps we have a
\0-delimited and use that last byte for an implicit \n?

	+ git tag -a -m valentin muss
	=================================================================
	==32504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d0000005ab at pc 0x556431ac3cac bp 0x7ffe67fcff50 sp 0x7ffe67fcff48
	READ of size 1 at 0x60d0000005ab thread T0
	    #0 0x556431ac3cab in parse_tag_buffer tag.c:155
	    #1 0x5564319194f3 in parse_object_buffer object.c:245
	    #2 0x556431919a11 in parse_object object.c:298
	    #3 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    #4 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    #5 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#6 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    #7 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#8 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#9 0x5564314168ff in run_builtin git.c:466
	    git#10 0x5564314172ab in handle_builtin git.c:720
	    git#11 0x5564314179d5 in run_argv git.c:787
	    git#12 0x55643141874f in cmd_main git.c:920
	    git#13 0x556431695a4d in main common-main.c:56
	    git#14 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#15 0x556431412209 in _start (git+0x1d2209)

	0x60d0000005ab is located 0 bytes to the right of 139-byte region [0x60d000000520,0x60d0000005ab)
	allocated by thread T0 here:
	    #0 0x7fa9ba5fc9cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
	    #1 0x556431b3f334 in do_xmalloc wrapper.c:51
	    #2 0x556431b3f43a in do_xmallocz wrapper.c:85
	    #3 0x556431b3f4ab in xmallocz wrapper.c:93
	    #4 0x556431902114 in unpack_loose_rest object-file.c:1312
	    #5 0x556431902ed9 in loose_object_info object-file.c:1479
	    git#6 0x556431903785 in do_oid_object_info_extended object-file.c:1577
	    #7 0x556431903b2d in oid_object_info_extended object-file.c:1639
	    git#8 0x556431903f3f in read_object object-file.c:1671
	    git#9 0x5564319043c7 in read_object_file_extended object-file.c:1714
	    git#10 0x556431917ff0 in repo_read_object_file object-store.h:253
	    git#11 0x5564319198b3 in parse_object object.c:290
	    git#12 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    git#13 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    git#14 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#15 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    git#16 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#17 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#18 0x5564314168ff in run_builtin git.c:466
	    git#19 0x5564314172ab in handle_builtin git.c:720
	    git#20 0x5564314179d5 in run_argv git.c:787
	    git#21 0x55643141874f in cmd_main git.c:920
	    git#22 0x556431695a4d in main common-main.c:56
	    git#23 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#24 0x556431412209 in _start (git+0x1d2209)

	SUMMARY: AddressSanitizer: heap-buffer-overflow tag.c:155 in parse_tag_buffer
	Shadow bytes around the buggy address:
	  0x0c1a7fff8060: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
	  0x0c1a7fff8080: 00 03 fa fa fa fa fa fa fa fa fd fd fd fd fd fd
	  0x0c1a7fff8090: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
	  0x0c1a7fff80a0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
	=>0x0c1a7fff80b0: 00 00 00 00 00[03]fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	Shadow byte legend (one shadow byte represents 8 application bytes):

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
avar added a commit to avar/git that referenced this pull request Sep 14, 2022
This fails with e.g. this t9350-fast-export.sh test, perhaps we have a
\0-delimited and use that last byte for an implicit \n?

	+ git tag -a -m valentin muss
	=================================================================
	==32504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d0000005ab at pc 0x556431ac3cac bp 0x7ffe67fcff50 sp 0x7ffe67fcff48
	READ of size 1 at 0x60d0000005ab thread T0
	    #0 0x556431ac3cab in parse_tag_buffer tag.c:155
	    #1 0x5564319194f3 in parse_object_buffer object.c:245
	    #2 0x556431919a11 in parse_object object.c:298
	    #3 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    #4 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    #5 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#6 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    #7 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#8 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#9 0x5564314168ff in run_builtin git.c:466
	    git#10 0x5564314172ab in handle_builtin git.c:720
	    git#11 0x5564314179d5 in run_argv git.c:787
	    git#12 0x55643141874f in cmd_main git.c:920
	    git#13 0x556431695a4d in main common-main.c:56
	    git#14 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#15 0x556431412209 in _start (git+0x1d2209)

	0x60d0000005ab is located 0 bytes to the right of 139-byte region [0x60d000000520,0x60d0000005ab)
	allocated by thread T0 here:
	    #0 0x7fa9ba5fc9cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
	    #1 0x556431b3f334 in do_xmalloc wrapper.c:51
	    #2 0x556431b3f43a in do_xmallocz wrapper.c:85
	    #3 0x556431b3f4ab in xmallocz wrapper.c:93
	    #4 0x556431902114 in unpack_loose_rest object-file.c:1312
	    #5 0x556431902ed9 in loose_object_info object-file.c:1479
	    git#6 0x556431903785 in do_oid_object_info_extended object-file.c:1577
	    #7 0x556431903b2d in oid_object_info_extended object-file.c:1639
	    git#8 0x556431903f3f in read_object object-file.c:1671
	    git#9 0x5564319043c7 in read_object_file_extended object-file.c:1714
	    git#10 0x556431917ff0 in repo_read_object_file object-store.h:253
	    git#11 0x5564319198b3 in parse_object object.c:290
	    git#12 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    git#13 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    git#14 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#15 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    git#16 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#17 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#18 0x5564314168ff in run_builtin git.c:466
	    git#19 0x5564314172ab in handle_builtin git.c:720
	    git#20 0x5564314179d5 in run_argv git.c:787
	    git#21 0x55643141874f in cmd_main git.c:920
	    git#22 0x556431695a4d in main common-main.c:56
	    git#23 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#24 0x556431412209 in _start (git+0x1d2209)

	SUMMARY: AddressSanitizer: heap-buffer-overflow tag.c:155 in parse_tag_buffer
	Shadow bytes around the buggy address:
	  0x0c1a7fff8060: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
	  0x0c1a7fff8080: 00 03 fa fa fa fa fa fa fa fa fd fd fd fd fd fd
	  0x0c1a7fff8090: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
	  0x0c1a7fff80a0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
	=>0x0c1a7fff80b0: 00 00 00 00 00[03]fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	Shadow byte legend (one shadow byte represents 8 application bytes):

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
avar added a commit to avar/git that referenced this pull request Sep 15, 2022
This fails with e.g. this t9350-fast-export.sh test, perhaps we have a
\0-delimited and use that last byte for an implicit \n?

	+ git tag -a -m valentin muss
	=================================================================
	==32504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d0000005ab at pc 0x556431ac3cac bp 0x7ffe67fcff50 sp 0x7ffe67fcff48
	READ of size 1 at 0x60d0000005ab thread T0
	    #0 0x556431ac3cab in parse_tag_buffer tag.c:155
	    #1 0x5564319194f3 in parse_object_buffer object.c:245
	    #2 0x556431919a11 in parse_object object.c:298
	    #3 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    #4 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    #5 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#6 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    #7 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#8 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#9 0x5564314168ff in run_builtin git.c:466
	    git#10 0x5564314172ab in handle_builtin git.c:720
	    git#11 0x5564314179d5 in run_argv git.c:787
	    git#12 0x55643141874f in cmd_main git.c:920
	    git#13 0x556431695a4d in main common-main.c:56
	    git#14 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#15 0x556431412209 in _start (git+0x1d2209)

	0x60d0000005ab is located 0 bytes to the right of 139-byte region [0x60d000000520,0x60d0000005ab)
	allocated by thread T0 here:
	    #0 0x7fa9ba5fc9cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
	    #1 0x556431b3f334 in do_xmalloc wrapper.c:51
	    #2 0x556431b3f43a in do_xmallocz wrapper.c:85
	    #3 0x556431b3f4ab in xmallocz wrapper.c:93
	    #4 0x556431902114 in unpack_loose_rest object-file.c:1312
	    #5 0x556431902ed9 in loose_object_info object-file.c:1479
	    git#6 0x556431903785 in do_oid_object_info_extended object-file.c:1577
	    #7 0x556431903b2d in oid_object_info_extended object-file.c:1639
	    git#8 0x556431903f3f in read_object object-file.c:1671
	    git#9 0x5564319043c7 in read_object_file_extended object-file.c:1714
	    git#10 0x556431917ff0 in repo_read_object_file object-store.h:253
	    git#11 0x5564319198b3 in parse_object object.c:290
	    git#12 0x5564319e2e96 in write_ref_to_lockfile refs/files-backend.c:1781
	    git#13 0x5564319e71e8 in lock_ref_for_update refs/files-backend.c:2590
	    git#14 0x5564319e7db5 in files_transaction_prepare refs/files-backend.c:2763
	    git#15 0x5564319d41d9 in ref_transaction_prepare refs.c:2146
	    git#16 0x5564319d4465 in ref_transaction_commit refs.c:2195
	    git#17 0x5564316706b9 in cmd_tag builtin/tag.c:630
	    git#18 0x5564314168ff in run_builtin git.c:466
	    git#19 0x5564314172ab in handle_builtin git.c:720
	    git#20 0x5564314179d5 in run_argv git.c:787
	    git#21 0x55643141874f in cmd_main git.c:920
	    git#22 0x556431695a4d in main common-main.c:56
	    git#23 0x7fa9ba2aa81c in __libc_start_main ../csu/libc-start.c:332
	    git#24 0x556431412209 in _start (git+0x1d2209)

	SUMMARY: AddressSanitizer: heap-buffer-overflow tag.c:155 in parse_tag_buffer
	Shadow bytes around the buggy address:
	  0x0c1a7fff8060: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
	  0x0c1a7fff8080: 00 03 fa fa fa fa fa fa fa fa fd fd fd fd fd fd
	  0x0c1a7fff8090: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
	  0x0c1a7fff80a0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
	=>0x0c1a7fff80b0: 00 00 00 00 00[03]fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff80f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	  0x0c1a7fff8100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
	Shadow byte legend (one shadow byte represents 8 application bytes):

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 26, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing the
directory's contents and the directory itself. However, the function
responsible for recursively removing the contents and directory,
remove_dir_recurse() calls opendir(3) and closedir(3). This can be problematic
because these functions allocate and free memory, which are not
async-signal-safe functions. This can lead to deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where we create a
temporary quarantine directory "incoming". Incoming objects will be written to
this directory before they get moved to the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80 <main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc (bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60, flags=0, close_fd=true, fd=5) at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>) at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>, bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160) at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ () from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

To prevent this, add a flag REMOVE_DIR_SIGNAL that allows remove_dir_recurse()
to know that a signal is being handled and avoid calling opendir(3).
One implication of this change is that when signal handling, the temporary
directory may not get cleaned up properly.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 26, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing the
directory's contents and the directory itself. However, the function
responsible for recursively removing the contents and directory,
remove_dir_recurse() calls opendir(3) and closedir(3). This can be problematic
because these functions allocate and free memory, which are not
async-signal-safe functions. This can lead to deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where we create a
temporary quarantine directory "incoming". Incoming objects will be written to
this directory before they get moved to the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc (bytes=bytes@entry=32816)
		at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60, flags=0,
		close_fd=true, fd=5) at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>) at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

To prevent this, add a flag REMOVE_DIR_SIGNAL that allows remove_dir_recurse()
to know that a signal is being handled and avoid calling opendir(3).
One implication of this change is that when signal handling, the temporary
directory may not get cleaned up properly.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 26, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

To prevent this, add a flag REMOVE_DIR_SIGNAL that allows
remove_dir_recurse() to know that a signal is being handled and avoid
calling opendir(3). One implication of this change is that when
signal handling, the temporary directory may not get cleaned up
properly.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 26, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

To prevent this, add a flag REMOVE_DIR_SIGNAL that allows
remove_dir_recurse() to know that a signal is being handled and avoid
calling opendir(3). One implication of this change is that when
signal handling, the temporary directory may not get cleaned up
properly.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 27, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 27, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 28, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

Signed-off-by: John Cai <johncai86@gmail.com>
john-cai added a commit to john-cai/git that referenced this pull request Sep 30, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

In the event of a normal exit, we should still be cleaning up via the
atexit() handler.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: John Cai <johncai86@gmail.com>
gitster pushed a commit that referenced this pull request Oct 2, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	#11 0x0000557c19dbe5f4 in git_inflate_init ()
	#12 0x0000557c19cee02a in unpack_compressed_entry ()
	#13 0x0000557c19cf08cb in unpack_entry ()
	#14 0x0000557c19cf0f32 in packed_object_info ()
	#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	#16 0x0000557c19cd6e2b in read_object_file_extended ()
	#17 0x0000557c19cdec2f in parse_object ()
	#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	#19 0x0000557c19d69309 in mark_uninteresting ()
	#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	#21 0x0000557c19d21678 in for_each_ref ()
	#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	#24 0x0000557c19b29fdd in handle_builtin ()
	#25 0x0000557c19b2a526 in cmd_main ()
	#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

In the event of a normal exit, we should still be cleaning up via the
atexit() handler.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rudyrigot pushed a commit to rudyrigot/git that referenced this pull request Oct 28, 2022
In the tmp-objdir api, tmp_objdir_create will create a temporary
directory but also register signal handlers responsible for removing
the directory's contents and the directory itself. However, the
function responsible for recursively removing the contents and
directory, remove_dir_recurse() calls opendir(3) and closedir(3).
This can be problematic because these functions allocate and free
memory, which are not async-signal-safe functions. This can lead to
deadlocks.

One place we call tmp_objdir_create() is in git-receive-pack, where
we create a temporary quarantine directory "incoming". Incoming
objects will be written to this directory before they get moved to
the object directory.

We have observed this code leading to a deadlock:

	Thread 1 (Thread 0x7f621ba0b200 (LWP 326305)):
	#0  __lll_lock_wait_private (futex=futex@entry=0x7f621bbf8b80
		<main_arena>) at ./lowlevellock.c:35
	#1  0x00007f621baa635b in __GI___libc_malloc
		(bytes=bytes@entry=32816) at malloc.c:3064
	#2  0x00007f621bae9f49 in __alloc_dir (statp=0x7fff2ea7ed60,
		flags=0, close_fd=true, fd=5)
		at ../sysdeps/posix/opendir.c:118
	#3  opendir_tail (fd=5) at ../sysdeps/posix/opendir.c:69
	#4  __opendir (name=<optimized out>)
		at ../sysdeps/posix/opendir.c:92
	#5  0x0000557c19c77de1 in remove_dir_recurse ()
	git#6  0x0000557c19d81a4f in remove_tmp_objdir_on_signal ()
	#7  <signal handler called>
	git#8  _int_malloc (av=av@entry=0x7f621bbf8b80 <main_arena>,
		bytes=bytes@entry=7160) at malloc.c:4116
	git#9  0x00007f621baa62c9 in __GI___libc_malloc (bytes=7160)
		at malloc.c:3066
	git#10 0x00007f621bd1e987 in inflateInit2_ ()
		from /opt/gitlab/embedded/lib/libz.so.1
	git#11 0x0000557c19dbe5f4 in git_inflate_init ()
	git#12 0x0000557c19cee02a in unpack_compressed_entry ()
	git#13 0x0000557c19cf08cb in unpack_entry ()
	git#14 0x0000557c19cf0f32 in packed_object_info ()
	git#15 0x0000557c19cd68cd in do_oid_object_info_extended ()
	git#16 0x0000557c19cd6e2b in read_object_file_extended ()
	git#17 0x0000557c19cdec2f in parse_object ()
	git#18 0x0000557c19c34977 in lookup_commit_reference_gently ()
	git#19 0x0000557c19d69309 in mark_uninteresting ()
	git#20 0x0000557c19d2d180 in do_for_each_repo_ref_iterator ()
	git#21 0x0000557c19d21678 in for_each_ref ()
	git#22 0x0000557c19d6a94f in assign_shallow_commits_to_refs ()
	git#23 0x0000557c19bc02b2 in cmd_receive_pack ()
	git#24 0x0000557c19b29fdd in handle_builtin ()
	git#25 0x0000557c19b2a526 in cmd_main ()
	git#26 0x0000557c19b28ea2 in main ()

Since we can't do the cleanup in a portable and signal-safe way, skip
the cleanup when we're handling a signal.

This means that when signal handling, the temporary directory may not
get cleaned up properly. This is mitigated by b3cecf4 (tmp-objdir: new
API for creating temporary writable databases, 2021-12-06) which changed
the default name and allows gc to clean up these temporary directories.

In the event of a normal exit, we should still be cleaning up via the
atexit() handler.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster pushed a commit that referenced this pull request Jan 17, 2023
It is possible to trigger an integer overflow when parsing attribute
names when there are more than 2^31 of them for a single pattern. This
can either lead to us dying due to trying to request too many bytes:

     blob=$(perl -e 'print "f" . " a=" x 2147483649' | git hash-object -w --stdin)
     git update-index --add --cacheinfo 100644,$blob,.gitattributes
     git attr-check --all file

    =================================================================
    ==1022==ERROR: AddressSanitizer: requested allocation size 0xfffffff800000032 (0xfffffff800001038 after adjustments for alignment, red zones etc.) exceeds maximum supported size of 0x10000000000 (thread T0)
        #0 0x7fd3efabf411 in __interceptor_calloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
        #1 0x5563a0a1e3d3 in xcalloc wrapper.c:150
        #2 0x5563a058d005 in parse_attr_line attr.c:384
        #3 0x5563a058e661 in handle_attr_line attr.c:660
        #4 0x5563a058eddb in read_attr_from_index attr.c:769
        #5 0x5563a058ef12 in read_attr attr.c:797
        #6 0x5563a058f24c in bootstrap_attr_stack attr.c:867
        #7 0x5563a058f4a3 in prepare_attr_stack attr.c:902
        #8 0x5563a05905da in collect_some_attrs attr.c:1097
        #9 0x5563a059093d in git_all_attrs attr.c:1128
        #10 0x5563a02f636e in check_attr builtin/check-attr.c:67
        #11 0x5563a02f6c12 in cmd_check_attr builtin/check-attr.c:183
        #12 0x5563a02aa993 in run_builtin git.c:466
        #13 0x5563a02ab397 in handle_builtin git.c:721
        #14 0x5563a02abb2b in run_argv git.c:788
        #15 0x5563a02ac991 in cmd_main git.c:926
        #16 0x5563a05432bd in main common-main.c:57
        #17 0x7fd3ef82228f  (/usr/lib/libc.so.6+0x2328f)

    ==1022==HINT: if you don't care about these errors you may set allocator_may_return_null=1
    SUMMARY: AddressSanitizer: allocation-size-too-big /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77 in __interceptor_calloc
    ==1022==ABORTING

Or, much worse, it can lead to an out-of-bounds write because we
underallocate and then memcpy(3P) into an array:

    perl -e '
        print "A " . "\rh="x2000000000;
        print "\rh="x2000000000;
        print "\rh="x294967294 . "\n"
    ' >.gitattributes
    git add .gitattributes
    git commit -am "evil attributes"

    $ git clone --quiet /path/to/repo
    =================================================================
    ==15062==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000002550 at pc 0x5555559884d5 bp 0x7fffffffbc60 sp 0x7fffffffbc58
    WRITE of size 8 at 0x602000002550 thread T0
        #0 0x5555559884d4 in parse_attr_line attr.c:393
        #1 0x5555559884d4 in handle_attr_line attr.c:660
        #2 0x555555988902 in read_attr_from_index attr.c:784
        #3 0x555555988902 in read_attr_from_index attr.c:747
        #4 0x555555988a1d in read_attr attr.c:800
        #5 0x555555989b0c in bootstrap_attr_stack attr.c:882
        #6 0x555555989b0c in prepare_attr_stack attr.c:917
        #7 0x555555989b0c in collect_some_attrs attr.c:1112
        #8 0x55555598b141 in git_check_attr attr.c:1126
        #9 0x555555a13004 in convert_attrs convert.c:1311
        #10 0x555555a95e04 in checkout_entry_ca entry.c:553
        #11 0x555555d58bf6 in checkout_entry entry.h:42
        #12 0x555555d58bf6 in check_updates unpack-trees.c:480
        #13 0x555555d5eb55 in unpack_trees unpack-trees.c:2040
        #14 0x555555785ab7 in checkout builtin/clone.c:724
        #15 0x555555785ab7 in cmd_clone builtin/clone.c:1384
        #16 0x55555572443c in run_builtin git.c:466
        #17 0x55555572443c in handle_builtin git.c:721
        #18 0x555555727872 in run_argv git.c:788
        #19 0x555555727872 in cmd_main git.c:926
        #20 0x555555721fa0 in main common-main.c:57
        #21 0x7ffff73f1d09 in __libc_start_main ../csu/libc-start.c:308
        #22 0x555555723f39 in _start (git+0x1cff39)

    0x602000002552 is located 0 bytes to the right of 2-byte region [0x602000002550,0x602000002552) allocated by thread T0 here:
        #0 0x7ffff768c037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x555555d7fff7 in xcalloc wrapper.c:150
        #2 0x55555598815f in parse_attr_line attr.c:384
        #3 0x55555598815f in handle_attr_line attr.c:660
        #4 0x555555988902 in read_attr_from_index attr.c:784
        #5 0x555555988902 in read_attr_from_index attr.c:747
        #6 0x555555988a1d in read_attr attr.c:800
        #7 0x555555989b0c in bootstrap_attr_stack attr.c:882
        #8 0x555555989b0c in prepare_attr_stack attr.c:917
        #9 0x555555989b0c in collect_some_attrs attr.c:1112
        #10 0x55555598b141 in git_check_attr attr.c:1126
        #11 0x555555a13004 in convert_attrs convert.c:1311
        #12 0x555555a95e04 in checkout_entry_ca entry.c:553
        #13 0x555555d58bf6 in checkout_entry entry.h:42
        #14 0x555555d58bf6 in check_updates unpack-trees.c:480
        #15 0x555555d5eb55 in unpack_trees unpack-trees.c:2040
        #16 0x555555785ab7 in checkout builtin/clone.c:724
        #17 0x555555785ab7 in cmd_clone builtin/clone.c:1384
        #18 0x55555572443c in run_builtin git.c:466
        #19 0x55555572443c in handle_builtin git.c:721
        #20 0x555555727872 in run_argv git.c:788
        #21 0x555555727872 in cmd_main git.c:926
        #22 0x555555721fa0 in main common-main.c:57
        #23 0x7ffff73f1d09 in __libc_start_main ../csu/libc-start.c:308

    SUMMARY: AddressSanitizer: heap-buffer-overflow attr.c:393 in parse_attr_line
    Shadow bytes around the buggy address:
      0x0c047fff8450: fa fa 00 02 fa fa 00 07 fa fa fd fd fa fa 00 00
      0x0c047fff8460: fa fa 02 fa fa fa fd fd fa fa 00 06 fa fa 05 fa
      0x0c047fff8470: fa fa fd fd fa fa 00 02 fa fa 06 fa fa fa 05 fa
      0x0c047fff8480: fa fa 07 fa fa fa fd fd fa fa 00 01 fa fa 00 02
      0x0c047fff8490: fa fa 00 03 fa fa 00 fa fa fa 00 01 fa fa 00 03
    =>0x0c047fff84a0: fa fa 00 01 fa fa 00 02 fa fa[02]fa fa fa fa fa
      0x0c047fff84b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x0c047fff84c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x0c047fff84d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x0c047fff84e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      0x0c047fff84f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
    Shadow byte legend (one shadow byte represents 8 application bytes):
      Addressable:           00
      Partially addressable: 01 02 03 04 05 06 07
      Heap left redzone:       fa
      Freed heap region:       fd
      Stack left redzone:      f1
      Stack mid redzone:       f2
      Stack right redzone:     f3
      Stack after return:      f5
      Stack use after scope:   f8
      Global redzone:          f9
      Global init order:       f6
      Poisoned by user:        f7
      Container overflow:      fc
      Array cookie:            ac
      Intra object redzone:    bb
      ASan internal:           fe
      Left alloca redzone:     ca
      Right alloca redzone:    cb
      Shadow gap:              cc
    ==15062==ABORTING

Fix this bug by using `size_t` instead to count the number of attributes
so that this value cannot reasonably overflow without running out of
memory before already.

Reported-by: Markus Vervier <markus.vervier@x41-dsec.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster pushed a commit that referenced this pull request Aug 19, 2024
It was recently reported that concurrent reads and writes may cause the
reftable backend to segfault. The root cause of this is that we do not
properly keep track of reftable readers across reloads.

Suppose that you have a reftable iterator and then decide to reload the
stack while iterating through the iterator. When the stack has been
rewritten since we have created the iterator, then we would end up
discarding a subset of readers that may still be in use by the iterator.
The consequence is that we now try to reference deallocated memory,
which of course segfaults.

One way to trigger this is in t5616, where some background maintenance
jobs have been leaking from one test into another. This leads to stack
traces like the following one:

  + git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 --refetch origin
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==657994==ERROR: AddressSanitizer: SEGV on unknown address 0x7fa0f0ec6089 (pc 0x55f23e52ddf9 bp
0x7ffe7bfa1700 sp 0x7ffe7bfa1700 T0)
  ==657994==The signal is caused by a READ memory access.
      #0 0x55f23e52ddf9 in get_var_int reftable/record.c:29
      #1 0x55f23e53295e in reftable_decode_keylen reftable/record.c:170
      #2 0x55f23e532cc0 in reftable_decode_key reftable/record.c:194
      #3 0x55f23e54e72e in block_iter_next reftable/block.c:398
      #4 0x55f23e5573dc in table_iter_next_in_block reftable/reader.c:240
      #5 0x55f23e5573dc in table_iter_next reftable/reader.c:355
      #6 0x55f23e5573dc in table_iter_next reftable/reader.c:339
      #7 0x55f23e551283 in merged_iter_advance_subiter reftable/merged.c:69
      #8 0x55f23e55169e in merged_iter_next_entry reftable/merged.c:123
      #9 0x55f23e55169e in merged_iter_next_void reftable/merged.c:172
      #10 0x55f23e537625 in reftable_iterator_next_ref reftable/generic.c:175
      #11 0x55f23e2cf9c6 in reftable_ref_iterator_advance refs/reftable-backend.c:464
      #12 0x55f23e2d996e in ref_iterator_advance refs/iterator.c:13
      #13 0x55f23e2d996e in do_for_each_ref_iterator refs/iterator.c:452
      #14 0x55f23dca6767 in get_ref_map builtin/fetch.c:623
      #15 0x55f23dca6767 in do_fetch builtin/fetch.c:1659
      #16 0x55f23dca6767 in fetch_one builtin/fetch.c:2133
      #17 0x55f23dca6767 in cmd_fetch builtin/fetch.c:2432
      #18 0x55f23dba7764 in run_builtin git.c:484
      #19 0x55f23dba7764 in handle_builtin git.c:741
      #20 0x55f23dbab61e in run_argv git.c:805
      #21 0x55f23dbab61e in cmd_main git.c:1000
      #22 0x55f23dba4781 in main common-main.c:64
      #23 0x7fa0f063fc89 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
      #24 0x7fa0f063fd44 in __libc_start_main_impl ../csu/libc-start.c:360
      #25 0x55f23dba6ad0 in _start (git+0xadfad0) (BuildId: 803b2b7f59beb03d7849fb8294a8e2145dd4aa27)

While it is somewhat awkward that the maintenance processes survive
tests in the first place, it is totally expected that reftables should
work alright with concurrent writers. Seemingly they don't.

The only underlying resource that we need to care about in this context
is the reftable reader, which is responsible for reading a single table
from disk. These readers get discarded immediately (unless reused) when
calling `reftable_stack_reload()`, which is wrong. We can only close
them once we know that there are no iterators using them anymore.

Prepare for a fix by converting the reftable readers to be refcounted.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster pushed a commit that referenced this pull request Aug 22, 2024
It was recently reported that concurrent reads and writes may cause the
reftable backend to segfault. The root cause of this is that we do not
properly keep track of reftable readers across reloads.

Suppose that you have a reftable iterator and then decide to reload the
stack while iterating through the iterator. When the stack has been
rewritten since we have created the iterator, then we would end up
discarding a subset of readers that may still be in use by the iterator.
The consequence is that we now try to reference deallocated memory,
which of course segfaults.

One way to trigger this is in t5616, where some background maintenance
jobs have been leaking from one test into another. This leads to stack
traces like the following one:

  + git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 --refetch origin
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==657994==ERROR: AddressSanitizer: SEGV on unknown address 0x7fa0f0ec6089 (pc 0x55f23e52ddf9 bp
0x7ffe7bfa1700 sp 0x7ffe7bfa1700 T0)
  ==657994==The signal is caused by a READ memory access.
      #0 0x55f23e52ddf9 in get_var_int reftable/record.c:29
      #1 0x55f23e53295e in reftable_decode_keylen reftable/record.c:170
      #2 0x55f23e532cc0 in reftable_decode_key reftable/record.c:194
      #3 0x55f23e54e72e in block_iter_next reftable/block.c:398
      #4 0x55f23e5573dc in table_iter_next_in_block reftable/reader.c:240
      #5 0x55f23e5573dc in table_iter_next reftable/reader.c:355
      #6 0x55f23e5573dc in table_iter_next reftable/reader.c:339
      #7 0x55f23e551283 in merged_iter_advance_subiter reftable/merged.c:69
      #8 0x55f23e55169e in merged_iter_next_entry reftable/merged.c:123
      #9 0x55f23e55169e in merged_iter_next_void reftable/merged.c:172
      #10 0x55f23e537625 in reftable_iterator_next_ref reftable/generic.c:175
      #11 0x55f23e2cf9c6 in reftable_ref_iterator_advance refs/reftable-backend.c:464
      #12 0x55f23e2d996e in ref_iterator_advance refs/iterator.c:13
      #13 0x55f23e2d996e in do_for_each_ref_iterator refs/iterator.c:452
      #14 0x55f23dca6767 in get_ref_map builtin/fetch.c:623
      #15 0x55f23dca6767 in do_fetch builtin/fetch.c:1659
      #16 0x55f23dca6767 in fetch_one builtin/fetch.c:2133
      #17 0x55f23dca6767 in cmd_fetch builtin/fetch.c:2432
      #18 0x55f23dba7764 in run_builtin git.c:484
      #19 0x55f23dba7764 in handle_builtin git.c:741
      #20 0x55f23dbab61e in run_argv git.c:805
      #21 0x55f23dbab61e in cmd_main git.c:1000
      #22 0x55f23dba4781 in main common-main.c:64
      #23 0x7fa0f063fc89 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
      #24 0x7fa0f063fd44 in __libc_start_main_impl ../csu/libc-start.c:360
      #25 0x55f23dba6ad0 in _start (git+0xadfad0) (BuildId: 803b2b7f59beb03d7849fb8294a8e2145dd4aa27)

While it is somewhat awkward that the maintenance processes survive
tests in the first place, it is totally expected that reftables should
work alright with concurrent writers. Seemingly they don't.

The only underlying resource that we need to care about in this context
is the reftable reader, which is responsible for reading a single table
from disk. These readers get discarded immediately (unless reused) when
calling `reftable_stack_reload()`, which is wrong. We can only close
them once we know that there are no iterators using them anymore.

Prepare for a fix by converting the reftable readers to be refcounted.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster pushed a commit that referenced this pull request Aug 23, 2024
It was recently reported that concurrent reads and writes may cause the
reftable backend to segfault. The root cause of this is that we do not
properly keep track of reftable readers across reloads.

Suppose that you have a reftable iterator and then decide to reload the
stack while iterating through the iterator. When the stack has been
rewritten since we have created the iterator, then we would end up
discarding a subset of readers that may still be in use by the iterator.
The consequence is that we now try to reference deallocated memory,
which of course segfaults.

One way to trigger this is in t5616, where some background maintenance
jobs have been leaking from one test into another. This leads to stack
traces like the following one:

  + git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 --refetch origin
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==657994==ERROR: AddressSanitizer: SEGV on unknown address 0x7fa0f0ec6089 (pc 0x55f23e52ddf9 bp
0x7ffe7bfa1700 sp 0x7ffe7bfa1700 T0)
  ==657994==The signal is caused by a READ memory access.
      #0 0x55f23e52ddf9 in get_var_int reftable/record.c:29
      #1 0x55f23e53295e in reftable_decode_keylen reftable/record.c:170
      #2 0x55f23e532cc0 in reftable_decode_key reftable/record.c:194
      #3 0x55f23e54e72e in block_iter_next reftable/block.c:398
      #4 0x55f23e5573dc in table_iter_next_in_block reftable/reader.c:240
      #5 0x55f23e5573dc in table_iter_next reftable/reader.c:355
      #6 0x55f23e5573dc in table_iter_next reftable/reader.c:339
      #7 0x55f23e551283 in merged_iter_advance_subiter reftable/merged.c:69
      #8 0x55f23e55169e in merged_iter_next_entry reftable/merged.c:123
      #9 0x55f23e55169e in merged_iter_next_void reftable/merged.c:172
      #10 0x55f23e537625 in reftable_iterator_next_ref reftable/generic.c:175
      #11 0x55f23e2cf9c6 in reftable_ref_iterator_advance refs/reftable-backend.c:464
      #12 0x55f23e2d996e in ref_iterator_advance refs/iterator.c:13
      #13 0x55f23e2d996e in do_for_each_ref_iterator refs/iterator.c:452
      #14 0x55f23dca6767 in get_ref_map builtin/fetch.c:623
      #15 0x55f23dca6767 in do_fetch builtin/fetch.c:1659
      #16 0x55f23dca6767 in fetch_one builtin/fetch.c:2133
      #17 0x55f23dca6767 in cmd_fetch builtin/fetch.c:2432
      #18 0x55f23dba7764 in run_builtin git.c:484
      #19 0x55f23dba7764 in handle_builtin git.c:741
      #20 0x55f23dbab61e in run_argv git.c:805
      #21 0x55f23dbab61e in cmd_main git.c:1000
      #22 0x55f23dba4781 in main common-main.c:64
      #23 0x7fa0f063fc89 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
      #24 0x7fa0f063fd44 in __libc_start_main_impl ../csu/libc-start.c:360
      #25 0x55f23dba6ad0 in _start (git+0xadfad0) (BuildId: 803b2b7f59beb03d7849fb8294a8e2145dd4aa27)

While it is somewhat awkward that the maintenance processes survive
tests in the first place, it is totally expected that reftables should
work alright with concurrent writers. Seemingly they don't.

The only underlying resource that we need to care about in this context
is the reftable reader, which is responsible for reading a single table
from disk. These readers get discarded immediately (unless reused) when
calling `reftable_stack_reload()`, which is wrong. We can only close
them once we know that there are no iterators using them anymore.

Prepare for a fix by converting the reftable readers to be refcounted.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants