git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Per Cederqvist <cederp@opera.com>
To: git@vger.kernel.org
Subject: "git branch HEAD" dumps core when on detached head (NULL pointer dereference)
Date: Thu, 21 Feb 2013 13:27:25 +0100	[thread overview]
Message-ID: <512612AD.4000609@opera.com> (raw)

Running "git branch HEAD" may be a stupid thing to do. It actually
was a mistake on my part. Still, I don't think git should dereference
a NULL pointer.

Tested using git 1.8.1.4 adn 1.8.1.1.

Repeat by:

     mkdir branchcrash || exit 1
     cd branchcrash
     git init
     touch a; git add a; git commit -m"Added a".
     touch b; git add b; git commit -m"Added b".
     git checkout HEAD^
     git branch HEAD

The last command dumps core.  gdb session:

gdb /usr/local/bin/git core
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /usr/local/bin/git...done.
[New LWP 7174]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `git branch HEAD'.
Program terminated with signal 11, Segmentation fault.
#0  cmd_branch (argc=1, argv=0x7fffe6e2a0f0, prefix=<optimized out>)
     at builtin/branch.c:919
919			strbuf_addf(&buf, "refs/remotes/%s", branch->name);
(gdb) bt
#0  cmd_branch (argc=1, argv=0x7fffe6e2a0f0, prefix=<optimized out>)
     at builtin/branch.c:919
#1  0x00000000004046ac in run_builtin (argv=0x7fffe6e2a0f0, argc=2,
     p=<optimized out>) at git.c:273
#2  handle_internal_command (argc=2, argv=0x7fffe6e2a0f0) at git.c:434
#3  0x0000000000404df3 in run_argv (argv=0x7fffe6e29f90, 
argcp=0x7fffe6e29f9c)
     at git.c:480
#4  main (argc=2, argv=0x7fffe6e2a0f0) at git.c:555
(gdb) p branch
$1 = (struct branch *) 0x0
(gdb) quit

     /ceder

             reply	other threads:[~2013-02-21 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21 12:27 Per Cederqvist [this message]
2013-02-21 12:50 ` "git branch HEAD" dumps core when on detached head (NULL pointer dereference) Duy Nguyen
2013-02-21 13:24   ` Per Cederqvist
2013-02-21 13:32     ` Duy Nguyen
2013-02-21 14:18 ` [PATCH] branch: segfault fixes and validation Nguyễn Thái Ngọc Duy
2013-02-21 17:47   ` Junio C Hamano
2013-02-22 11:47     ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2013-02-22 20:27       ` Junio C Hamano
2013-02-23 12:22         ` [PATCH v3] " Nguyễn Thái Ngọc Duy
2013-02-23 20:01           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512612AD.4000609@opera.com \
    --to=cederp@opera.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).