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

Re: [PATCH v3] rerere: fix crashes due to unmatched opening conflict markers

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 12, 2024, 23:37 UTC
Message-ID
<xmqqr0fai23t.fsf@gitster.g>
In-Reply-To
<20240409121708.131542-2-marcel@roethke.info>
Marcel Röthke <marcel@roethke.info> writes:
Show 6 quoted lines
> When rerere handles a conflict with an unmatched opening conflict marker
> in a file with other conflicts, it will fail create a preimage and also
> fail allocate the status member of struct rerere_dir. Currently the
> status member is allocated after the error handling. This will lead to a
> SEGFAULT when the status member is accessed during cleanup of the failed
> parse.

Nicely diagnosed. Yes, such a corrupt preimage should not enter the rerere database as it is unusable for future replaying of the resolution. rerere should be prepared to deal with such an input more gracefully.

Show 8 quoted lines
> Additionally, in subsequent executions of rerere, after removing the
> MERGE_RR.lock manually, rerere crashes for a similar reason. MERGE_RR
> points to a conflict id that has no preimage, therefore the status
> member is not allocated and a SEGFAULT happens when trying to check if a
> preimage exists.
>
> Solve this by making sure the status field is allocated correctly and add
> tests to prevent the bug from reoccurring.
Thanks.
> This does not fix the root cause, failing to parse stray conflict
> markers, but I don't think we can do much better than recognizing it,
> printing an error, and moving on gracefully.

I somehow doubt that "parse stray markers" is something we _want_ to do in the first place. Is it "the root cause" that we refuse/reject such a corrupt input from entering the rerere database? To me, it seems like that the issue is that we do not do a very good job rejecting them, keeping the internal state consistent.

Show 20 quoted lines
>  rerere.c          |  5 ++++
>  t/t4200-rerere.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>
> diff --git a/rerere.c b/rerere.c
> index ca7e77ba68..4683d6cbb1 100644
> --- a/rerere.c
> +++ b/rerere.c
> @@ -219,6 +219,11 @@ static void read_rr(struct repository *r, struct string_list *rr)
>  		buf.buf[hexsz] = '\0';
>  		id = new_rerere_id_hex(buf.buf);
>  		id->variant = variant;
> +		/*
> +		 * make sure id->collection->status has enough space
> +		 * for the variant we are interested in
> +		 */
> +		fit_variant(id->collection, variant);
>  		string_list_insert(rr, path)->util = id;
>  	}
>  	strbuf_release(&buf);
Both the fix, and the newly added tests, look great to me.
Thanks.  Will queue.
Previous: Marcel RöthkeNext: Junio C Hamano
Message 12 of 15 in “rerere: fix crash in during clear”
  1. rerere: fix crash in during clearMarcel Röthke, Feb 18, 2024
  2. Kristoffer HaugsbakkFeb 18, 2024
  3. Marcel RöthkeFeb 18, 2024
  4. rerere: fix crash during clearMarcel Röthke, Feb 18, 2024
  5. Junio C HamanoFeb 20, 2024
  6. Marcel RöthkeFeb 24, 2024
  7. Junio C HamanoMar 24, 2024
  8. Marcel RöthkeMar 25, 2024
  9. Marcel RöthkeApr 7, 2024
  10. Junio C HamanoApr 8, 2024
  11. rerere: fix crashes due to unmatched opening conflict markersMarcel Röthke, Apr 9, 2024
  12. Junio C HamanoApr 12, 2024
  13. Junio C HamanoApr 15, 2024
  14. Marcel RöthkeApr 16, 2024
  15. rerere: fix crashes due to unmatched opening conflict markersMarcel Röthke, Apr 16, 2024

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.