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

bug found on the new git maintenance builtin command

From
Rafael Silva <rafaeloliveira.cs@gmail.com>
Date
Sep 14, 2020, 19:49 UTC
Message-ID
<20200914194938.GA4235@contrib-buster.localdomain>
Hi Everyone,

I found a minor bug when testing the new maintenance built-in command that was introduced on 679768e2a1 (maintenance: create basic maintenance runner, 2020-08-25) submitted in [1]

When running `git maintenance` without argument it receives a segmentation fault. I'm running git built on the current `seen` branch that is pointing to bf3e2864f3 (Merge branch 'ds/maintenance-part-3' into seen, 2020-09-11)

I did a little investigation and it seems the command needs to check when no arguments are passed to the cmd_maintanance() function and either quit with usage or redirect to man.

To reproduce the error, just run the `git maintenance` without any arguments

$ git maintenance Segmentation fault

Analysign with GDB right before the SEGFAULT are thrown, we can see the argv[1] pointing to NULL as follows:

(gdb) list 1628 int cmd_maintenance(int argc, const char **argv, const char *prefix) 1629 { 1630 if (argc == 2 && !strcmp(argv[1], "-h")) 1631 usage(builtin_maintenance_usage); 1632 1633 fprintf(stdout, "run"); 1634 if (!strcmp(argv[1], "run")) 1635 return maintenance_run(argc - 1, argv + 1, prefix); 1636 if (!strcmp(argv[1], "start")) 1637 return maintenance_start(); (gdb) print argc $5 = 1 (gdb) print argv[1] $6 = 0x0

Hope all this information helps with the fixing it

[1] Patch submission can be found in: https://public-inbox.org/git/aa961af387b7f458f75ad60b9a2a45da4bb43794.1599224956.git.gitgitgadget@gmail.com/

Regards, Rafael Silva

Next: Derrick Stolee
Message 1 of 3 in “bug found on the new git maintenance builtin command”
  1. Rafael SilvaSep 14, 2020
  2. Derrick StoleeSep 14, 2020
  3. Junio C HamanoSep 14, 2020

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.