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

Re: [PATCH 08/10] revert: Introduce HEAD, TODO files to persist state, plan

From
Jeff King <peff@peff.net>
Date
Jun 2, 2011, 14:29 UTC
Message-ID
<20110602142933.GA32487@sigill.intra.peff.net>
In-Reply-To
<BANLkTinc=9aW_y6s-Zb578QsMawnxFD55Q@mail.gmail.com>
On Thu, Jun 02, 2011 at 06:23:03PM +0530, Ramkumar Ramachandra wrote:
Show 10 quoted lines
> On a slightly unrelated note, I just found out that the persist_todo
> can't be called twice due to a lockfile API limitation* -- the
> atexit(3) cleanup handler is supposed to have a linked list of
> lockfiles to clean up. When one lockfile is used twice, it becomes a
> circularly linked list, and the entire program hangs at exit time
> since traversing a circularly linked list is never-ending. Couple of
> comments:
> 1. By reading the lockfile implementation, I understand why this
> happens -- can't it be implemented differently to remove this
> limitation? If not, shouldn't this limitation be documented somewhere?
Doesn't lock_file handle multiple locking already via the on_list parameter?
    $ grep -A2 on_list lockfile.c
            if (!lk->on_list) {
                    lk->next = lock_file_list;
                    lock_file_list = lk;
                    lk->on_list = 1;
            }

However, I think you have a bigger problem, which is that you are allocating the lock_file on the stack in persist_todo and persist_head. So by the time the atexit() handler is called, this storage has gone away and you are just reading random data (not to mention that it also should be zero-initialized before being passed to lock_file).

-Peff
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 32 of 37 in “Sequencer Foundations”
  1. 00/10 Sequencer FoundationsRamkumar Ramachandra, May 25, 2011
  2. 01/10 advice: Introduce error_resolve_conflictRamkumar Ramachandra, May 25, 2011
  3. 02/10 revert: Propogate errors upwards from do_pick_commitRamkumar Ramachandra, May 25, 2011
  4. Junio C HamanoMay 25, 2011
  5. Ramkumar RamachandraMay 26, 2011
  6. 03/10 revert: Eliminate global "commit" variableRamkumar Ramachandra, May 25, 2011
  7. Junio C HamanoMay 25, 2011
  8. 04/10 revert: Rename no_replay to record_originRamkumar Ramachandra, May 25, 2011
  9. 05/10 revert: Introduce struct to keep command-line optionsRamkumar Ramachandra, May 25, 2011
  10. 06/10 revert: Separate cmdline parsing from functional codeRamkumar Ramachandra, May 25, 2011
  11. 07/10 revert: Catch incompatible command-line options earlyRamkumar Ramachandra, May 25, 2011
  12. 08/10 revert: Introduce HEAD, TODO files to persist state, planRamkumar Ramachandra, May 25, 2011
  13. 09/10 revert: Implement parsing --continue, --abort and --skipRamkumar Ramachandra, May 25, 2011
  14. 10/10 revert: Implement --abort processingRamkumar Ramachandra, May 25, 2011
  15. Junio C HamanoMay 25, 2011
  16. 00/10 Sequencer FoundationsRamkumar Ramachandra, May 26, 2011
  17. 01/10 advice: Introduce error_resolve_conflictRamkumar Ramachandra, May 26, 2011
  18. 02/10 revert: Propogate errors upwards from do_pick_commitRamkumar Ramachandra, May 26, 2011
  19. 03/10 revert: Eliminate global "commit" variableRamkumar Ramachandra, May 26, 2011
  20. 04/10 revert: Rename no_replay to record_originRamkumar Ramachandra, May 26, 2011
  21. 05/10 revert: Introduce struct to keep command-line optionsRamkumar Ramachandra, May 26, 2011
  22. 06/10 revert: Separate cmdline parsing from functional codeRamkumar Ramachandra, May 26, 2011
  23. 07/10 revert: Catch incompatible command-line options earlyRamkumar Ramachandra, May 26, 2011
  24. 08/10 revert: Introduce HEAD, TODO files to persist state, planRamkumar Ramachandra, May 26, 2011
  25. Jonathan NiederMay 26, 2011
  26. Ramkumar RamachandraMay 26, 2011
  27. Ramkumar RamachandraMay 26, 2011
  28. Junio C HamanoMay 26, 2011
  29. Ramkumar RamachandraJun 1, 2011
  30. Jonathan NiederJun 1, 2011
  31. Ramkumar RamachandraJun 2, 2011
  32. Jeff KingJun 2, 2011
  33. Ramkumar RamachandraJun 8, 2011
  34. 09/10 revert: Implement parsing --continue, --abort and --skipRamkumar Ramachandra, May 26, 2011
  35. 10/10 revert: Implement --abort processingRamkumar Ramachandra, May 26, 2011
  36. Junio C HamanoMay 26, 2011
  37. Ramkumar RamachandraMay 27, 2011

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.