On Wed, Nov 24, 2021 at 1:00 AM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > On Tue, Nov 23, 2021 at 8:54 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > Thanks for spotting this. Has this patch ever been tested with > > sanitizer? Do we have gap in test coverage? > > The question about potential gap in test coverage is a good one. > Maybe, by chance it reallocated the same memory that it had earlier > freed, thus did indeed work "by accident". Another possibility is that > Ævar only ran the tests after applying the full patch series, in which > case this dangling-pointer bug would be gone, rather than running the > tests after each patch. As a follow-up, I just applied this patch alone and ran the tests, and they do indeed fail as expected (on my macOS). In t2400-worktree-add.sh, alone, 44 out of 71 tests failed, thus I don't think there's a gap in test coverage. So, the most likely explanation of how this problem slipped through is that Ævar only tested after applying the full series, in which case the dangling pointer bug would be gone, rather than testing after each patch.