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

Re: [PATCH 0/6] [RFC] Create a 'safe' strbuf API

From
Derrick Stolee <stolee@gmail.com>
Date
Oct 6, 2026, 14:33 UTC
Message-ID
<0f466dc6-f9c5-48ee-bb94-f3e8a951ee5d@gmail.com>
In-Reply-To
<20260923194628.GA44327@coredump.intra.peff.net>
On 9/23/2026 3:46 PM, Jeff King wrote:
Show 7 quoted lines
> On Sat, Sep 19, 2026 at 04:23:41PM +0100, Phillip Wood wrote:
> 
>>> The goal of this short RFC, such as it is, is to get some feedback on
>>> whether this is a worthwhile direction to pursue or if I should abandon this
>>> idea of having this definition of "safe" for some APIs. This decision may
>>> also determine if we should abandon ds/trace2-tolerate-failed-timestamps or
>>> leave the existing behavior as-is.
> Yeah, I don't love the term "safe" here for two reasons:
...> So what I had imagined when seeing the initial subject lines was not
Show 16 quoted lines
> strbufs who report malloc errors, but rather strbuf-like functions that
> operate on a fixed-size buffer (with either a static max-size like 4k,
> or perhaps a per-variable max-size recorded in the struct).
> 
> You can still run into errors, of course; we might run out of room in
> the buffer. But we'd see those cases deterministically for a given
> input, rather than occasionally when races or other external factors
> cause malloc to unexpectedly fail.
> 
>> For the strbuf API having to check for failure on every function call does
>> not sound attractive, I think having a sticky error bit like the stdio
>> functions so that one can build a string and check there have been no
>> failures once just before using it would be a nicer approach.
> 
> Agreed. I think that is a good approach for the static_strbuf idea
> above, too.

Thanks for taking the time to consider the RFC. Sorry I'm so late in responding, but I find your feedback insightful. It requires starting over on this direction, but I don't currently have time to do so. Maybe I'll give this a try again in the future, but I'll set it down for now.

Thanks, -Stolee

Previous: Jeff King
Message 17 of 17 in “[RFC] Create a 'safe' strbuf API”
  1. 0/6 [RFC] Create a 'safe' strbuf APIDerrick Stolee via GitGitGadget, Sep 18, 2026
  2. 1/6 strbuf: add header for 'safe' APIDerrick Stolee via GitGitGadget, Sep 18, 2026
  3. Junio C HamanoSep 21, 2026
  4. Mark C. Chu-CarrollSep 23, 2026
  5. Junio C HamanoSep 23, 2026
  6. 2/6 wrapper: initialize GIT_ALLOC_LIMIT proactivelyDerrick Stolee via GitGitGadget, Sep 18, 2026
  7. 3/6 wrapper: create safe_memory_limit_check()Derrick Stolee via GitGitGadget, Sep 18, 2026
  8. Junio C HamanoSep 21, 2026
  9. 4/6 strbuf-safe: add sstrbuf_grow()Derrick Stolee via GitGitGadget, Sep 18, 2026
  10. Junio C HamanoSep 21, 2026
  11. 5/6 json-writer: include strbuf-safe.hDerrick Stolee via GitGitGadget, Sep 18, 2026
  12. 6/6 strbuf-safe: add init and release methodsDerrick Stolee via GitGitGadget, Sep 18, 2026
  13. Junio C HamanoSep 21, 2026
  14. Junio C HamanoSep 21, 2026
  15. Phillip WoodSep 19, 2026
  16. Jeff KingSep 23, 2026
  17. Derrick StoleeOct 6, 2026

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.