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

Re: [PATCH v2 1/6] odb: introduce interface to generate packfiles

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 21, 2026, 06:34 UTC
Message-ID
<aofxjYAYPGkCrtQ7@pks.im>
In-Reply-To
<CABPp-BHSFW38sF4dZkqZuGaRASVRj2FVG2NN1OTA7-Dd6Pt6rw@mail.gmail.com>
On Thu, Aug 20, 2026 at 09:41:03PM -0700, Elijah Newren wrote:
Show 53 quoted lines
> On Wed, Aug 19, 2026 at 11:01 PM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > On Wed, Aug 19, 2026 at 09:56:56AM -0700, Elijah Newren wrote:
> > > On Sun, Aug 16, 2026 at 10:40 PM Patrick Steinhardt <ps@pks.im> wrote:
> > > >
> > > > +static int odb_source_files_generate_pack(struct odb_source *source UNUSED,
> > > > +                                         struct odb_pack_generator **out,
> > > > +                                         const struct odb_generate_pack_options *opts)
> > > > +{
> > > > +       struct child_process cp = CHILD_PROCESS_INIT;
> > > > +       struct odb_pack_generator_files *generator;
> > > > +       FILE *in;
> > > [...]
> > > > +       cp.clean_on_exit = 1;
> > > > +
> > > > +       if (start_command(&cp))
> > > > +               return error(_("could not spawn pack-objects"));
> > > [...]
> > > > +       CALLOC_ARRAY(generator, 1);
> > > > +       generator->base.out = opts->pack_fd < 0 ? cp.out : -1;
> > > > +       generator->base.err = opts->progress_fd < 0 ? cp.err : -1;
> > > > +       generator->base.finish = odb_pack_generator_files_finish;
> > > > +       generator->cp = cp;
> > > > +
> > > > +       *out = &generator->base;
> > > > +       return 0;
> > > > +}
> > >
> > > Does this have a use-after-scope bug lurking here, due to the
> > > combination of clean_on_exit = 1 (which makes a copy of &cp for later
> > > use), and the fact that cp is a function-local?  If I'm reading the
> > > code right, start_command() calls mark_child_for_cleanup(), which does
> > >
> > >     p->process = process;  /* where process is &cp */
> > >
> > > and then cleanup_children() accesses various fields under p->process.
> > > You do copy the necessary fields from cp to generator->cp, but
> > > &generator->cp was not passed to start_command(), so p->process points
> > > to the function-local cp.
> >
> > Oh, that's a very good catch indeed. Out of curiosity, how did you end
> > up discovering this? Did you just happen to remember that we store the
> > pointer out of scope or did the copy make you have a deeper look?
> 
> Neither.  Went to review the series, but I was worried I'd be missing
> context from not reviewing earlier odb refactorings.  Used AI to help
> orient me and give me its own findings from reviewing your patches.
> (AI will sometimes spot things I miss in a review, though it'll also
> miss some things I catch.)  And sometimes I iterate with AI to dig
> into various areas.  Anyway, it flagged the potential problem, and I
> dug in to make sure it didn't look like a hallucination before
> cleaning it up and passing it on.  I'm still looking through your
> other patches in this series, but should finish soon.

I agree. For all the pain AI is causing, doing reviews is one of the things where it's helping me a ton. Both by reviewing my own patch series before I send them out, and by reviewing others.

Thanks!
Patrick
Previous: Elijah NewrenNext: Patrick Steinhardt
Message 19 of 58 in “odb: make packfile generation pluggable”
  1. 0/5 odb: make packfile generation pluggablePatrick Steinhardt, Aug 7, 2026
  2. 1/5 odb: introduce interface to generate packfilesPatrick Steinhardt, Aug 7, 2026
  3. 2/5 upload-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 7, 2026
  4. 3/5 send-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 7, 2026
  5. 4/5 builtin/bundle: refactor option handling for progress meterPatrick Steinhardt, Aug 7, 2026
  6. 5/5 bundle: generate packfiles via the object databasePatrick Steinhardt, Aug 7, 2026
  7. Junio C HamanoAug 13, 2026
  8. Patrick SteinhardtAug 14, 2026
  9. Junio C HamanoAug 7, 2026
  10. Patrick SteinhardtAug 10, 2026
  11. Taylor BlauAug 12, 2026
  12. Patrick SteinhardtAug 13, 2026
  13. Junio C HamanoAug 13, 2026
  14. 0/6 odb: make packfile generation pluggablePatrick Steinhardt, Aug 17, 2026
  15. 1/6 odb: introduce interface to generate packfilesPatrick Steinhardt, Aug 17, 2026
  16. Elijah NewrenAug 19, 2026
  17. Patrick SteinhardtAug 20, 2026
  18. Elijah NewrenAug 21, 2026
  19. Patrick SteinhardtAug 21, 2026
  20. 2/6 upload-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 17, 2026
  21. 3/6 send-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 17, 2026
  22. 4/6 builtin/bundle: refactor option handling for progress meterPatrick Steinhardt, Aug 17, 2026
  23. 5/6 bundle: get (mostly) rid of `the_repository`Patrick Steinhardt, Aug 17, 2026
  24. Junio C HamanoAug 17, 2026
  25. Patrick SteinhardtAug 18, 2026
  26. Elijah NewrenAug 21, 2026
  27. Patrick SteinhardtAug 21, 2026
  28. 6/6 bundle: generate packfiles via the object databasePatrick Steinhardt, Aug 17, 2026
  29. Justin ToblerAug 19, 2026
  30. Patrick SteinhardtAug 20, 2026
  31. 0/6 odb: make packfile generation pluggablePatrick Steinhardt, Aug 20, 2026
  32. 1/6 odb: introduce interface to generate packfilesPatrick Steinhardt, Aug 20, 2026
  33. Karthik NayakAug 20, 2026
  34. Patrick SteinhardtAug 20, 2026
  35. Junio C HamanoAug 20, 2026
  36. Patrick SteinhardtAug 21, 2026
  37. 2/6 upload-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 20, 2026
  38. Karthik NayakAug 20, 2026
  39. Patrick SteinhardtAug 20, 2026
  40. Karthik NayakAug 20, 2026
  41. 3/6 send-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 20, 2026
  42. 4/6 builtin/bundle: refactor option handling for progress meterPatrick Steinhardt, Aug 20, 2026
  43. Karthik NayakAug 20, 2026
  44. 5/6 bundle: get (mostly) rid of `the_repository`Patrick Steinhardt, Aug 20, 2026
  45. 6/6 bundle: generate packfiles via the object databasePatrick Steinhardt, Aug 20, 2026
  46. Karthik NayakAug 20, 2026
  47. Patrick SteinhardtAug 20, 2026
  48. Karthik NayakAug 20, 2026
  49. Patrick SteinhardtAug 20, 2026
  50. Elijah NewrenAug 21, 2026
  51. 0/6 odb: make packfile generation pluggablePatrick Steinhardt, Aug 21, 2026
  52. 1/6 odb: introduce interface to generate packfilesPatrick Steinhardt, Aug 21, 2026
  53. 2/6 upload-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 21, 2026
  54. 3/6 send-pack: generate packfiles via the object databasePatrick Steinhardt, Aug 21, 2026
  55. 4/6 builtin/bundle: refactor option handling for progress meterPatrick Steinhardt, Aug 21, 2026
  56. 5/6 bundle: get (mostly) rid of `the_repository`Patrick Steinhardt, Aug 21, 2026
  57. 6/6 bundle: generate packfiles via the object databasePatrick Steinhardt, Aug 21, 2026
  58. Karthik NayakAug 21, 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.