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

Re: [PATCH v3 1/6] common-main.o: move non-trace2 exit() behavior out of trace2.c

From
Josh Steadmon <steadmon@google.com>
Date
Jun 7, 2022, 20:09 UTC
Message-ID
<Yp+wjCPhqieTku3X@google.com>
In-Reply-To
<patch-v3-1.6-9c4f8d840e9-20220602T122106Z-avarab@gmail.com>
On 2022.06.02 14:25, Ævar Arnfjörð Bjarmason wrote:
Show 32 quoted lines
> Change the exit() wrapper added in ee4512ed481 (trace2: create new
> combined trace facility, 2019-02-22) so that we'll split up the trace2
> logging concerns from wanting to wrap the "exit()" function itself for
> other purposes.
> 
> This makes more sense structurally, as we won't seem to conflate
> non-trace2 behavior with the trace2 code. I'd previously added an
> explanation for this in 368b5843158 (common-main.c: call exit(), don't
> return, 2021-12-07), that comment is being adjusted here.
> 
> Now the only thing we'll do if we're not using trace2 is to truncate
> the "code" argument to the lowest 8 bits.
> 
> We only need to do that truncation on non-POSIX systems, but in
> ee4512ed481 that "if defined(__MINGW32__)" code added in
> 47e3de0e796 (MinGW: truncate exit()'s argument to lowest 8 bits,
> 2009-07-05) was made to run everywhere. It might be good for clarify
> to narrow that down by an "ifdef" again, but I'm not certain that in
> the interim we haven't had some other non-POSIX systems rely the
> behavior. On a POSIX system taking the lowest 8 bits is implicit, see
> exit(3)[1] and wait(2)[2]. Let's leave a comment about that instead.
> 
> 1. https://man7.org/linux/man-pages/man3/exit.3.html
> 2. https://man7.org/linux/man-pages/man2/wait.2.html
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  common-main.c     | 20 ++++++++++++++++----
>  git-compat-util.h |  4 ++--
>  trace2.c          |  8 ++------
>  trace2.h          |  8 +-------
>  4 files changed, 21 insertions(+), 19 deletions(-)
Just realized that this unexpectedly breaks the fuzzer builds:
$ git checkout ab/bug-if-bug
$ make CC=clang CXX=clang++ \
   CFLAGS="-fsanitize=fuzzer-no-link,address" \
   LIB_FUZZING_ENGINE="-fsanitize=fuzzer" \
   fuzz-all
[...]
    LINK fuzz-pack-headers
    LINK fuzz-pack-idx
/usr/bin/ld: archive.o: in function `parse_archive_args':
archive.c:(.text.parse_archive_args[parse_archive_args]+0x2cb8): undefined reference to `common_exit'
[...]

The issue is that we don't link the fuzzers against common-main.o because the fuzzing engine provides its own main(). Would it be too much of a pain to move this out to a new common-exit.c file?

Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 40 of 49 in “usage API: add and use a bug() + BUG_if_bug()”
  1. 0/5 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  2. 1/5 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, May 21, 2022
  3. Junio C HamanoMay 25, 2022
  4. Junio C HamanoMay 26, 2022
  5. Ævar Arnfjörð BjarmasonMay 26, 2022
  6. Junio C HamanoMay 26, 2022
  7. Ævar Arnfjörð BjarmasonMay 26, 2022
  8. Junio C HamanoMay 26, 2022
  9. Ævar Arnfjörð BjarmasonMay 31, 2022
  10. Josh SteadmonMay 27, 2022
  11. Junio C HamanoMay 27, 2022
  12. 2/5 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, May 21, 2022
  13. Josh SteadmonMay 27, 2022
  14. 3/5 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, May 21, 2022
  15. Junio C HamanoMay 25, 2022
  16. 4/5 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  17. Junio C HamanoMay 25, 2022
  18. Josh SteadmonMay 27, 2022
  19. Andrei RybakMay 27, 2022
  20. 5/5 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  21. Glen ChooMay 27, 2022
  22. Josh SteadmonMay 27, 2022
  23. 0/6 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  24. 1/6 common-main.o: move non-trace2 exit() behavior out of trace2.cÆvar Arnfjörð Bjarmason, May 31, 2022
  25. Junio C HamanoJun 1, 2022
  26. 2/6 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, May 31, 2022
  27. Glen ChooMay 31, 2022
  28. Junio C HamanoJun 1, 2022
  29. 3/6 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, May 31, 2022
  30. 4/6 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, May 31, 2022
  31. Josh SteadmonMay 31, 2022
  32. Junio C HamanoJun 1, 2022
  33. 5/6 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  34. 6/6 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  35. Junio C HamanoJun 1, 2022
  36. Josh SteadmonMay 31, 2022
  37. 0/6 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  38. 1/6 common-main.o: move non-trace2 exit() behavior out of trace2.cÆvar Arnfjörð Bjarmason, Jun 2, 2022
  39. Junio C HamanoJun 3, 2022
  40. Josh SteadmonJun 7, 2022
  41. Ævar Arnfjörð BjarmasonJun 7, 2022
  42. Josh SteadmonJun 7, 2022
  43. 3/6 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  44. 2/6 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  45. 5/6 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  46. 4/6 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, Jun 2, 2022
  47. 6/6 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  48. Junio C HamanoJun 2, 2022
  49. Glen ChooJun 2, 2022

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.