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

[BUG] realloc failed

From
Kazuki Tsujimoto <kazuki@callcc.net>
Date
May 21, 2011, 01:01 UTC
Message-ID
<20110521100126.E3CD.BA9123DE@callcc.net>
The following command causes "fatal: Out of memory, realloc failed" error.

$ ./git --version git version 1.7.5.GIT

$ cat ~/.gitconfig
[alias]
    a = -c n=v status

$ MALLOC_CHECK_=0 ./git a fatal: Out of memory, realloc failed

$ gdb --args ./git a (gdb) run *** glibc detected *** /tmp/git/git: realloc(): invalid pointer: 0x00000000007cd328 *** ...snip... (gdb) bt #0 0x00007ffff72c8a75 in raise () from /lib/libc.so.6 #1 0x00007ffff72cc5c0 in abort () from /lib/libc.so.6 #2 0x00007ffff73024fb in ?? () from /lib/libc.so.6 #3 0x00007ffff730c5b6 in ?? () from /lib/libc.so.6 #4 0x00007ffff73132e2 in realloc () from /lib/libc.so.6 #5 0x0000000000510bfb in xrealloc (ptr=0x7cd328, size=16) at wrapper.c:82 #6 0x0000000000405013 in handle_alias (argcp=0x7fffffffdfdc, argv=0x7fffffffdfd0) at git.c:236 #7 0x000000000040550a in run_argv (argcp=0x7fffffffdfdc, argv=0x7fffffffdfd0) at git.c:515 #8 0x000000000040566a in main (argc=1, argv=0x7fffffffe0f0) at git.c:579

When the "-c" option is specified, setenv will be called in git_config_push_parameter. So it seems "envchanged" flag must be set to true in this case.

 git.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git.c b/git.c
index a5ef3c6..e04e4d4 100644
--- a/git.c
+++ b/git.c
@@ -153,6 +153,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				usage(git_usage_string);
 			}
 			git_config_push_parameter((*argv)[1]);
+			if (envchanged)
+				*envchanged = 1;
 			(*argv)++;
 			(*argc)--;
 		} else {

After applying this patch, it works.

$ ./git a
fatal: alias 'a' changes environment variables
You can use '!git' in the alias to do this.

$ vi ~/.gitconfig
[alias]
    a = !git -c n=v status
        ~~~~

$ ./git a
# On branch master
nothing to commit (working directory clean)
-- 
Kazuki Tsujimoto
Next: Junio C Hamano
Message 1 of 6 in “[BUG] realloc failed”
  1. Kazuki TsujimotoMay 21, 2011
  2. Junio C HamanoMay 21, 2011
  3. Kazuki TsujimotoMay 21, 2011
  4. Junio C HamanoMay 22, 2011
  5. Junio C HamanoMay 22, 2011
  6. Kazuki TsujimotoMay 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.