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

Re: [PATCH v2 1/4] xdiff: fix a memory leak

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Feb 17, 2022, 11:05 UTC
Message-ID
<08f1cc5f-672f-f806-49d9-a6d6be3d2a8b@gmail.com>
In-Reply-To
<220216.86h78yuar0.gmgdl@evledraar.gmail.com>
On 16/02/2022 14:38, Ævar Arnfjörð Bjarmason wrote:
Show 15 quoted lines
> [...]
>>> More generally I think this patch is taking the wrong approach, why are
>>> we trying to the members of a stack variable in xdl_do_diff(), when that
>>> variable isn't ours, but is created by our caller? Why aren't they
>>> dealing with it?
>>
>> They are not dealing with it because they do not initialize it - it is
>> an "out" parameter that is used to return data to the caller. This
>> patch changes the logic to "whoever initializes it is responsible for
>> freeing it if there is an error". By doing that we localize the error
>> handling to xdl_do_diff() and can leave the callers unchanged.
> 
> Yes, I'm saying that we're needlessly piling on complexity by continuing
> with this pattern in the xdiff/ codebase. I think it's fair to question
> the direction in general.

I think if there were a lot of these bugs that needed fixing then the wholesale changes to the way memory is managed you seem to be suggesting would be worth it. However I think the existing code is mostly correct so such a change would be a lot of churn and would absorb a lot of reviewer time that would be better spent elsewhere compared to fixing up the code we have.

Best Wishes
Phillip
Previous: Junio C HamanoNext: Phillip Wood via GitGitGadget
Message 15 of 18 in “xdiff: handle allocation failures”
  1. 0/3 xdiff: handle allocation failuresPhillip Wood via GitGitGadget, Feb 9, 2022
  2. 3/3 xdiff: handle allocation failure when mergingPhillip Wood via GitGitGadget, Feb 9, 2022
  3. 2/3 xdiff: refactor a functionPhillip Wood via GitGitGadget, Feb 9, 2022
  4. Junio C HamanoFeb 9, 2022
  5. Junio C HamanoFeb 10, 2022
  6. Phillip WoodFeb 11, 2022
  7. Junio C HamanoFeb 11, 2022
  8. 1/3 xdiff: handle allocation failure in patience diffPhillip Wood via GitGitGadget, Feb 9, 2022
  9. 0/4 xdiff: handle allocation failuresPhillip Wood via GitGitGadget, Feb 16, 2022
  10. 1/4 xdiff: fix a memory leakPhillip Wood via GitGitGadget, Feb 16, 2022
  11. Ævar Arnfjörð BjarmasonFeb 16, 2022
  12. Phillip WoodFeb 16, 2022
  13. Ævar Arnfjörð BjarmasonFeb 16, 2022
  14. Junio C HamanoFeb 16, 2022
  15. Phillip WoodFeb 17, 2022
  16. 2/4 xdiff: handle allocation failure in patience diffPhillip Wood via GitGitGadget, Feb 16, 2022
  17. 3/4 xdiff: refactor a functionPhillip Wood via GitGitGadget, Feb 16, 2022
  18. 4/4 xdiff: handle allocation failure when mergingPhillip Wood via GitGitGadget, Feb 16, 2022

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

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