Skip to content
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

merge-ort: clean up after failed merge #1307

Closed
wants to merge 2 commits into from

Conversation

dscho
Copy link
Member

@dscho dscho commented Jul 28, 2022

I was investigating why seen's CI runs fail, and came up with this fix.

Changes since v1:

  • Rebased onto en/merge-ort-perf.
  • Now we're not only cleaning up the merge data structure, but also leaving the Trace2 region when returning early from merge_switch_to_result().

Cc: Elijah Newren newren@gmail.com

@dscho
Copy link
Member Author

dscho commented Jul 29, 2022

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

Submitted as pull.1307.git.1659084748350.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1307/dscho/merge-ort-impl-leakfix-v1

To fetch this version to local tag pr-1307/dscho/merge-ort-impl-leakfix-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1307/dscho/merge-ort-impl-leakfix-v1

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

On the Git mailing list, Elijah Newren wrote (reply to this):

On Fri, Jul 29, 2022 at 1:52 AM Johannes Schindelin via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> In 9fefce68dc8 (merge-ort: basic outline for merge_switch_to_result(),
> 2020-12-13), we added functionality to lay down the result of a merge on
> disk. But we forgot to release the data structures in case
> `unpack_trees()` failed to run properly.
>
> This was pointed out by the `linux-leaks` job in our CI runs.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>     merge-ort: clean up after failed merge
>
>     I was investigating why seen's CI runs fail, and came up with this fix.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1307%2Fdscho%2Fmerge-ort-impl-leakfix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1307/dscho/merge-ort-impl-leakfix-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1307
>
>  merge-ort.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/merge-ort.c b/merge-ort.c
> index ee7fbe71404..61b9e90018b 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -1002,6 +1002,7 @@ void merge_switch_to_result(struct merge_options *opt,
>                 if (checkout(opt, head, result->tree)) {
>                         /* failure to function */
>                         result->clean = -1;
> +                       merge_finalize(opt, result);
>                         return;
>                 }
>
> @@ -1010,6 +1011,7 @@ void merge_switch_to_result(struct merge_options *opt,
>                                                     &opti->conflicted)) {
>                         /* failure to function */
>                         result->clean = -1;
> +                       merge_finalize(opt, result);
>                         return;
>                 }
>         }
>
> base-commit: 9fefce68dc85d96781090f86c067d83f7c50b617
> --
> gitgitgadget

Good catch.  Can you rebase on to a slightly newer commit?  I think we
also need a trace2_region_leave() call in each block as well, which is
only clear if you look at newer versions.

In 9fefce6 (merge-ort: basic outline for merge_switch_to_result(),
2020-12-13), we added functionality to lay down the result of a merge on
disk. But we forgot to release the data structures in case
`unpack_trees()` failed to run properly.

This was pointed out by the `linux-leaks` job in our CI runs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In 557ac03 (merge-ort: begin performance work; instrument with
trace2_region_* calls, 2021-01-23), we added Trace2 instrumentation, but
in the error path that returns early, we forgot to tell Trace2 that
we're leaving the region. Let's fix that.

Pointed-out-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Jul 29, 2022

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

Submitted as pull.1307.v2.git.1659114727.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1307/dscho/merge-ort-impl-leakfix-v2

To fetch this version to local tag pr-1307/dscho/merge-ort-impl-leakfix-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1307/dscho/merge-ort-impl-leakfix-v2

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

This branch is now known as js/ort-clean-up-after-failed-merge.

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

This patch series was integrated into seen via git@197e992.

@gitgitgadget gitgitgadget bot added the seen label Jul 29, 2022
@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

This patch series was integrated into seen via git@ac792f8.

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 29, 2022

There was a status update in the "New Topics" section about the branch js/ort-clean-up-after-failed-merge on the Git mailing list:

Plug memory leaks in the failure code path in the "merge-ort" merge
strategy backend.

Will merge to 'next'?
source: <pull.1307.v2.git.1659114727.gitgitgadget@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 30, 2022

On the Git mailing list, Elijah Newren wrote (reply to this):

On Fri, Jul 29, 2022 at 10:12 AM Johannes Schindelin via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> I was investigating why seen's CI runs fail, and came up with this fix.
>
> Changes since v1:
>
>  * Rebased onto en/merge-ort-perf.
>  * Now we're not only cleaning up the merge data structure, but also leaving
>    the Trace2 region when returning early from merge_switch_to_result().
>
> Johannes Schindelin (2):
>   merge-ort: clean up after failed merge
>   merge-ort: do leave Trace2 region even if checkout fails
>
>  merge-ort.c | 5 +++++
>  1 file changed, 5 insertions(+)

Thanks, series looks good to me:

Reviewed-by: Elijah Newren <newren@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 31, 2022

On the Git mailing list, Junio C Hamano wrote (reply to this):

Elijah Newren <newren@gmail.com> writes:

> On Fri, Jul 29, 2022 at 10:12 AM Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>>
>> I was investigating why seen's CI runs fail, and came up with this fix.
>>
>> Changes since v1:
>>
>>  * Rebased onto en/merge-ort-perf.
>>  * Now we're not only cleaning up the merge data structure, but also leaving
>>    the Trace2 region when returning early from merge_switch_to_result().
>>
>> Johannes Schindelin (2):
>>   merge-ort: clean up after failed merge
>>   merge-ort: do leave Trace2 region even if checkout fails
>>
>>  merge-ort.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> Thanks, series looks good to me:
>
> Reviewed-by: Elijah Newren <newren@gmail.com>

Thanks, both.

The new "leave" calls immediately next to the existing ones that
look identical appear duplicated, but correcting the logic first
in an obvious way like the posted patch, leaving any clean-up to
later, is a prudent thing to do.

Queued.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 1, 2022

This patch series was integrated into seen via git@0c11767.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 1, 2022

This patch series was integrated into next via git@0c9f02f.

@gitgitgadget gitgitgadget bot added the next label Aug 1, 2022
@gitgitgadget
Copy link

gitgitgadget bot commented Aug 1, 2022

There was a status update in the "Cooking" section about the branch js/ort-clean-up-after-failed-merge on the Git mailing list:

Plug memory leaks in the failure code path in the "merge-ort" merge
strategy backend.

Will merge to 'master'.
source: <pull.1307.v2.git.1659114727.gitgitgadget@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 3, 2022

This patch series was integrated into seen via git@c48a48f.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 5, 2022

This patch series was integrated into seen via git@4fe176f.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 6, 2022

There was a status update in the "Cooking" section about the branch js/ort-clean-up-after-failed-merge on the Git mailing list:

Plug memory leaks in the failure code path in the "merge-ort" merge
strategy backend.

Will merge to 'master'.
source: <pull.1307.v2.git.1659114727.gitgitgadget@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 7, 2022

This patch series was integrated into seen via git@3ec95b0.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 8, 2022

This patch series was integrated into seen via git@bac92b1.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 8, 2022

This patch series was integrated into master via git@bac92b1.

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 8, 2022

This patch series was integrated into next via git@bac92b1.

@gitgitgadget gitgitgadget bot added the master label Aug 8, 2022
@gitgitgadget
Copy link

gitgitgadget bot commented Aug 8, 2022

Closed via bac92b1.

@gitgitgadget gitgitgadget bot closed this Aug 8, 2022
@dscho dscho deleted the merge-ort-impl-leakfix branch August 8, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant