Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, didn't you say that the commit that introduced the problem was not yet upstreamed? But I see gitgitgadget@b0f1a41 being the identical patch, but targeting upstream's default branch...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, actually I first thought that it will be applicable there, but then started to investigate further and came to conclusion that it quite probably would not be relevant there and closed my PR.
Anyway, I've seen that you hinted in that PR something like that it still can be important in upstream, so I'll read your comments more thoroughly and then decide whether to continue working with upstream instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug described is not present in upstream (at least in the exact same scenario).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually rather convinced that the upstream contribution is the way we should go forward with: the patch is clearly fixing a bug that is caused by the combination of two upstream patches, and even if the current symptom cannot be seen with upstream's version, it is still a bug in upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate, please? I'm not aware of implicit assumptions taken in the codebase, and for me it's quite likely that they are implying that the code path in question should not request for config values of the global repository object... If that's not the case, I would be happy to make an upstream contribution with corresponding reasoning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In gitgitgadget@f9b7573#diff-8107da631aae41d1abfe44a6e2ee403d79b2bdf07398eb1f7737fefeb073c0acR43, code was added that releases the memory that
repo->commondir
points to, but it does not set that pointer toNULL
because the very next line sets it to something different.However, in gitgitgadget@357a03e#diff-8107da631aae41d1abfe44a6e2ee403d79b2bdf07398eb1f7737fefeb073c0acR59-R66, quite a bit of code (and a call to another function) was introduced between releasing that memory and setting it again.
This introduced the fragility in the code that eventually lead to the code path (currently only a problem in Git for Windows' fork).
One might argue that the bug is in the
windows.appendAtomically
code, but this would be an incorrect assessment: the fragile code was introduced by 357a03e and it was only a matter of time until a patch would trigger this fragility, in this instance 61cbb76.What 61cbb76 does is totally legitimate: it asks whether there is a
repo->commondir
to work with, and if there is, uses it. It's the fault of 357a03e that there is an unusable, non-NULL
repo->commondir
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, exactly what I thought (actually). I'll prepare the PR to upstream and get this discussion linked in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zwerdna you could simply reopen gitgitgadget#1402 :-)