git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] realloc failed
@ 2011-05-21  1:01 Kazuki Tsujimoto
  2011-05-21  1:35 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Kazuki Tsujimoto @ 2011-05-21  1:01 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-27 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-21  1:01 [BUG] realloc failed Kazuki Tsujimoto
2011-05-21  1:35 ` Junio C Hamano
2011-05-21  5:50   ` Kazuki Tsujimoto
2011-05-22 19:34     ` Junio C Hamano
2011-05-22 19:42       ` Junio C Hamano
2011-05-27 13:59         ` Kazuki Tsujimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).