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

Re: [PATCH 1/3] refs: push lock management into packed backend

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 18, 2023, 22:46 UTC
Message-ID
<xmqqa5tjje0y.fsf@gitster.g>
In-Reply-To
<dea0fbb139a82fe449a7edab6a8f445ce763d0c0.1695059978.git.gitgitgadget@gmail.com>
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 15 quoted lines
>  	struct ref_transaction *tr;
> +	int ret = 0;
>  	assert(err);
>  
>  	CALLOC_ARRAY(tr, 1);
>  	tr->ref_store = refs;
> +
> +	if (refs->be->transaction_begin)
> +		ret = refs->be->transaction_begin(refs, tr, err);
> +	if (ret) {
> +		free(tr);
> +		return NULL;
> +	}
>  	return tr;
>  }
This looks a bit more convoluted than necessary.  Is it the same as
	if (refs->be->transaction_begin &&
	    refs->be->transaction_begin(refs, tr, err))
		FREE_AND_NULL(tr);
Show 10 quoted lines
> +	if (backend_data->packed_transaction) { 
> +		if (backend_data->packed_transaction_needed) {
> +			ret = ref_transaction_commit(packed_transaction, err);
> +			if (ret)
> +				goto cleanup;
> +			/* TODO: leaks on error path. */
> +			ref_transaction_free(packed_transaction);
> +			packed_transaction = NULL;
> +			backend_data->packed_transaction = NULL;
> +		} else {

If it were just a matter of flipping the early return and freeing of the transaction before going to clean-up, then that would have been less effort than leaving the TODO: comment. What other things are needed to plug this leak?

Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys
Message 3 of 15 in “Simple reftable backend”
  1. 0/3 Simple reftable backendHan-Wen Nienhuys via GitGitGadget, Sep 18, 2023
  2. 1/3 refs: push lock management into packed backendHan-Wen Nienhuys via GitGitGadget, Sep 18, 2023
  3. Junio C HamanoSep 18, 2023
  4. Han-Wen NienhuysSep 19, 2023
  5. 2/3 refs: move is_packed_transaction_needed out of packed-backend.cHan-Wen Nienhuys via GitGitGadget, Sep 18, 2023
  6. 3/3 refs: alternate reftable ref backend implementationHan-Wen Nienhuys via GitGitGadget, Sep 18, 2023
  7. Junio C HamanoSep 18, 2023
  8. 0/6 RFC: simple reftable backendHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  9. 1/6 refs: construct transaction using a _begin callbackHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  10. 2/6 refs: wrap transaction in a debug-specific transactionHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  11. 3/6 refs: push lock management into packed backendHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  12. 4/6 refs: move is_packed_transaction_needed out of packed-backend.cHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  13. 6/6 refs: always try to do packed transactions for reftableHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  14. 5/6 refs: alternate reftable ref backend implementationHan-Wen Nienhuys via GitGitGadget, Sep 20, 2023
  15. Patrick SteinhardtSep 21, 2023

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.