{"thread":{"id":"21842","subject":"[BUG] crash on make test","startedAt":"2009-12-03T15:38:58Z","lastAt":"2009-12-04T17:12:52Z","messageCount":3,"participants":["Marinescu Paul dan","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"129123","messageId":"D6F784B72498304C93A8A4691967698E8EE2C44FE2@REX2.intranet.epfl.ch","threadId":"21842","inReplyTo":"D6F784B72498304C93A8A4691967698E8EE2C44FE1@REX2.intranet.epfl.ch","subject":"[BUG] crash on make test","fromName":"Marinescu Paul dan","fromEmail":"pauldan.marinescu@epfl.ch","sentAt":"2009-12-03T15:38:58Z","receivedAt":"2009-12-03T15:38:58Z","isPatch":false,"sender":{"key":"pauldan.marinescu@epfl.ch","avatar":null},"body":"\nI got a crash on git's make test with and a core file in ./t/trash directory.t4200-rerere/\nThe problem seems to be in garbage_collect (builtin-rerere.c) where readdir can be called with a null pointer\n\nBelow is the gdb stack trace:\n\nGNU gdb 6.8-debian\nCopyright (C) 2008 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"i486-linux-gnu\"...\nReading symbols from /lib/libz.so.1...done.\nLoaded symbols for /lib/libz.so.1\nReading symbols from /lib/i686/cmov/libcrypto.so.0.9.8...done.\nLoaded symbols for /lib/i686/cmov/libcrypto.so.0.9.8\nReading symbols from /lib/tls/i686/cmov/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/tls/i686/cmov/libpthread-2.9.so...done.\ndone.\nLoaded symbols for /lib/tls/i686/cmov/libpthread.so.0\nReading symbols from /lib/tls/i686/cmov/libc.so.6...Reading symbols from /usr/lib/debug/lib/tls/i686/cmov/libc-2.9.so...done.\ndone.\nLoaded symbols for /lib/tls/i686/cmov/libc.so.6\nReading symbols from /usr/lib/libxml2.so.2...done.\nLoaded symbols for /usr/lib/libxml2.so.2\nReading symbols from /lib/tls/i686/cmov/librt.so.1...Reading symbols from /usr/lib/debug/lib/tls/i686/cmov/librt-2.9.so...done.\ndone.\nLoaded symbols for /lib/tls/i686/cmov/librt.so.1\nReading symbols from /lib/tls/i686/cmov/libdl.so.2...Reading symbols from /usr/lib/debug/lib/tls/i686/cmov/libdl-2.9.so...done.\ndone.\nLoaded symbols for /lib/tls/i686/cmov/libdl.so.2\nReading symbols from /usr/lib/libelf.so.1...done.\nLoaded symbols for /usr/lib/libelf.so.1\nReading symbols from /usr/lib/libstdc++.so.6...done.\nLoaded symbols for /usr/lib/libstdc++.so.6\nReading symbols from /lib/tls/i686/cmov/libm.so.6...Reading symbols from /usr/lib/debug/lib/tls/i686/cmov/libm-2.9.so...done.\ndone.\nLoaded symbols for /lib/tls/i686/cmov/libm.so.6\nReading symbols from /lib/libgcc_s.so.1...done.\nLoaded symbols for /lib/libgcc_s.so.1\nReading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.9.so...done.\ndone.\nLoaded symbols for /lib/ld-linux.so.2\nCore was generated by `git rerere gc'.\nProgram terminated with signal 11, Segmentation fault.\n[New process 5637]\n#0  0x4027fca5 in __readdir64 (dirp=0x0) at ../sysdeps/unix/readdir.c:45\n in ../sysdeps/unix/readdir.c\n(gdb) bt full\n#0  0x4027fca5 in __readdir64 (dirp=0x0) at ../sysdeps/unix/readdir.c:45\n ignore1 = 0\n ignore2 = 1\n dp = <value optimized out>\n saved_errno = 12\n#1  0x0813cfd4 in garbage_collect (rr=0xbfabe89c) at builtin-rerere.c:51\n to_remove = {items = 0x0, nr = 0, alloc = 0, strdup_strings = 1}\n dir = (DIR *) 0x0\n e = (struct dirent *) 0x1\n i = 0\n cutoff = -1079252800\n now = 1259852637\n then = 1\n#2  0x0813d970 in cmd_rerere (argc=2, argv=0xbfabeaa8, prefix=0x0) at builtin-rerere.c:121\n merge_rr = {items = 0xa0d2728, nr = 1, alloc = 32, strdup_strings = 1}\n i = -1\n fd = 6\n#3  0x0804ca57 in run_builtin (p=0x831465c, argc=2, argv=0xbfabeaa8) at git.c:249\n status = 1076211824\n st = {st_dev = 3418922014550254984, __pad1 = 65535, __st_ino = 1073860596, st_mode = 134517300, \n  st_nlink = 1073862256, st_uid = 3215714640, st_gid = 1073798779, st_rdev = 4632177755147065384, __pad2 = 1, \n  st_size = 1, st_blksize = 134519071, st_blocks = 180, st_atim = {tv_sec = 137446088, tv_nsec = 1}, st_mtim = {\n    tv_sec = 1075774256, tv_nsec = 1077161972}, st_ctim = {tv_sec = 137183648, tv_nsec = 134524528}, \n  st_ino = 4612030924696840600}\n prefix = 0x0\n#4  0x0804cee8 in handle_internal_command (argc=2, argv=0xbfabeaa8) at git.c:394\n p = (struct cmd_struct *) 0x831465c\n cmd = 0xbfac098a \"rerere\"\n i = 69\n commands = {{cmd = 0x82d4765 \"add\", fn = 0x804f757 <cmd_add>, option = 5}, {cmd = 0x82d4769 \"stage\", \n    fn = 0x804f757 <cmd_add>, option = 5}, {cmd = 0x82d476f \"annotate\", fn = 0x8050754 <cmd_annotate>, option = 1}, {\n    cmd = 0x82d4778 \"apply\", fn = 0x80679e1 <cmd_apply>, option = 0}, {cmd = 0x82d477e \"archive\", \n    fn = 0x8069ba0 <cmd_archive>, option = 0}, {cmd = 0x82d4786 \"bisect--helper\", \n    fn = 0x806a138 <cmd_bisect__helper>, option = 5}, {cmd = 0x82d4795 \"blame\", fn = 0x807770d <cmd_blame>, \n    option = 1}, {cmd = 0x82d479b \"branch\", fn = 0x807d584 <cmd_branch>, option = 1}, {cmd = 0x82d47a2 \"bundle\", \n    fn = 0x807e3ec <cmd_bundle>, option = 0}, {cmd = 0x82d47a9 \"cat-file\", fn = 0x80803cb <cmd_cat_file>, \n    option = 1}, {cmd = 0x82d47b2 \"checkout\", fn = 0x8088f1c <cmd_checkout>, option = 5}, {\n    cmd = 0x82d47bb \"checkout-index\", fn = 0x8082fc9 <cmd_checkout_index>, option = 5}, {\n    cmd = 0x82d47ca \"check-ref-format\", fn = 0x8081920 <cmd_check_ref_format>, option = 0}, {\n    cmd = 0x82d47db \"check-attr\", fn = 0x808125a <cmd_check_attr>, option = 1}, {cmd = 0x82d47e6 \"cherry\", \n    fn = 0x80eb740 <cmd_cherry>, option = 1}, {cmd = 0x82d47ed \"cherry-pick\", fn = 0x814c341 <cmd_cherry_pick>, \n    option = 5}, {cmd = 0x82d47f9 \"clone\", fn = 0x808e8a1 <cmd_clone>, option = 0}, {cmd = 0x82d47ff \"clean\", \n    fn = 0x808aa34 <cmd_clean>, option = 5}, {cmd = 0x82d4805 \"commit\", fn = 0x809b274 <cmd_commit>, option = 5}, {\n    cmd = 0x82d480c \"commit-tree\", fn = 0x8092531 <cmd_commit_tree>, option = 1}, {cmd = 0x82d4818 \"config\", \n    fn = 0x809f881 <cmd_config>, option = 0}, {cmd = 0x82d481f \"count-objects\", fn = 0x80a1c75 <cmd_count_objects>, \n    option = 1}, {cmd = 0x82d482d \"describe\", fn = 0x80a4d6d <cmd_describe>, option = 1}, {cmd = 0x82d4836 \"diff\", \n    fn = 0x80a99e8 <cmd_diff>, option = 0}, {cmd = 0x82d483b \"diff-files\", fn = 0x80a56d0 <cmd_diff_files>, \n    option = 5}, {cmd = 0x82d4846 \"diff-index\", fn = 0x80a601c <cmd_diff_index>, option = 1}, {\n    cmd = 0x82d4851 \"diff-tree\", fn = 0x80a7307 <cmd_diff_tree>, option = 1}, {cmd = 0x82d485b \"fast-export\", \n    fn = 0x80af36f <cmd_fast_export>, option = 1}, {cmd = 0x82d4867 \"fetch\", fn = 0x80c1668 <cmd_fetch>, \n    option = 1}, {cmd = 0x82d486d \"fetch-pack\", fn = 0x80ba759 <cmd_fetch_pack>, option = 1}, {\n    cmd = 0x82d4878 \"fetch--tool\", fn = 0x80b4202 <cmd_fetch__tool>, option = 1}, {cmd = 0x82d4884 \"fmt-merge-msg\", \n    fn = 0x80c5038 <cmd_fmt_merge_msg>, option = 1}, {cmd = 0x82d4892 \"for-each-ref\", \n    fn = 0x80cb172 <cmd_for_each_ref>, option = 1}, {cmd = 0x82d489f \"format-patch\", \n    fn = 0x80e86a4 <cmd_format_patch>, option = 1}, {cmd = 0x82d48ac \"fsck\", fn = 0x80cf9d5 <cmd_fsck>, option = 1}, \n  {cmd = 0x82d48b1 \"fsck-objects\", fn = 0x80cf9d5 <cmd_fsck>, option = 1}, {cmd = 0x82d48be \"gc\", \n    fn = 0x80d17fd <cmd_gc>, option = 1}, {cmd = 0x82d48c1 \"get-tar-commit-id\", \n    fn = 0x8163545 <cmd_get_tar_commit_id>, option = 0}, {cmd = 0x82d48d3 \"grep\", fn = 0x80d80ba <cmd_grep>, \n    option = 3}, {cmd = 0x82d48d8 \"help\", fn = 0x80dcd12 <cmd_help>, option = 0}, {cmd = 0x82d48dd \"init\", \n    fn = 0x80e0d5b <cmd_init_db>, option = 0}, {cmd = 0x82d48e2 \"init-db\", fn = 0x80e0d5b <cmd_init_db>, \n    option = 0}, {cmd = 0x82d48ea \"log\", fn = 0x80e4c6f <cmd_log>, option = 3}, {cmd = 0x82d48ee \"ls-files\", \n    fn = 0x80ef3e5 <cmd_ls_files>, option = 1}, {cmd = 0x82d48f7 \"ls-tree\", fn = 0x80f1e84 <cmd_ls_tree>, \n    option = 1}, {cmd = 0x82d48ff \"ls-remote\", fn = 0x80f0a35 <cmd_ls_remote>, option = 0}, {\n    cmd = 0x82d4909 \"mailinfo\", fn = 0x80f99ac <cmd_mailinfo>, option = 0}, {cmd = 0x82d4912 \"mailsplit\", \n    fn = 0x80fbd21 <cmd_mailsplit>, option = 0}, {cmd = 0x82d491c \"merge\", fn = 0x81045ff <cmd_merge>, option = 5}, {\n    cmd = 0x82d4922 \"merge-base\", fn = 0x81084c3 <cmd_merge_base>, option = 1}, {cmd = 0x82d492d \"merge-file\", \n    fn = 0x8108839 <cmd_merge_file>, option = 0}, {cmd = 0x82d4938 \"merge-ours\", fn = 0x8109594 <cmd_merge_ours>, \n    option = 1}, {cmd = 0x82d4943 \"merge-recursive\", fn = 0x81097ca <cmd_merge_recursive>, option = 5}, {\n    cmd = 0x82d4953 \"merge-subtree\", fn = 0x81097ca <cmd_merge_recursive>, option = 5}, {cmd = 0x82d4961 \"mktree\", \n    fn = 0x810afea <cmd_mktree>, option = 1}, {cmd = 0x82d4968 \"mv\", fn = 0x810ba65 <cmd_mv>, option = 5}, {\n    cmd = 0x82d496b \"name-rev\", fn = 0x810ef35 <cmd_name_rev>, option = 1}, {cmd = 0x82d4974 \"pack-objects\", \n    fn = 0x811daed <cmd_pack_objects>, option = 1}, {cmd = 0x82d4981 \"peek-remote\", fn = 0x80f0a35 <cmd_ls_remote>, \n    option = 0}, {cmd = 0x82d498d \"pickaxe\", fn = 0x807770d <cmd_blame>, option = 1}, {cmd = 0x82d4995 \"prune\", \n    fn = 0x812160f <cmd_prune>, option = 1}, {cmd = 0x82d499b \"prune-packed\", fn = 0x812029c <cmd_prune_packed>, \n    option = 1}, {cmd = 0x82d49a8 \"push\", fn = 0x8122de2 <cmd_push>, option = 1}, {cmd = 0x82d49ad \"read-tree\", \n    fn = 0x8123640 <cmd_read_tree>, option = 1}, {cmd = 0x82d49b7 \"receive-pack\", fn = 0x8128ec4 <cmd_receive_pack>, \n    option = 0}, {cmd = 0x82d49c4 \"reflog\", fn = 0x812ebcf <cmd_reflog>, option = 1}, {cmd = 0x82d49cb \"remote\", \n    fn = 0x813ad5e <cmd_remote>, option = 1}, {cmd = 0x82d49d2 \"replace\", fn = 0x813c0fc <cmd_replace>, option = 1}, \n  {cmd = 0x82d49da \"repo-config\", fn = 0x809f881 <cmd_config>, option = 0}, {cmd = 0x82d49e6 \"rerere\", \n    fn = 0x813d60d <cmd_rerere>, option = 1}, {cmd = 0x82d49ed \"reset\", fn = 0x813f0c9 <cmd_reset>, option = 1}, {\n    cmd = 0x82d49f3 \"rev-list\", fn = 0x8142605 <cmd_rev_list>, option = 1}, {cmd = 0x82d49fc \"rev-parse\", \n    fn = 0x81461ab <cmd_rev_parse>, option = 0}, {cmd = 0x82d4a06 \"revert\", fn = 0x814c24b <cmd_revert>, \n    option = 5}, {cmd = 0x82d4a0d \"rm\", fn = 0x814d170 <cmd_rm>, option = 1}, {cmd = 0x82d4a10 \"send-pack\", \n    fn = 0x815167e <cmd_send_pack>, option = 1}, {cmd = 0x82d4a1a \"shortlog\", fn = 0x81547ad <cmd_shortlog>, \n    option = 2}, {cmd = 0x82d4a23 \"show-branch\", fn = 0x81590c0 <cmd_show_branch>, option = 1}, {\n    cmd = 0x82d4a2f \"show\", fn = 0x80e3cc2 <cmd_show>, option = 3}, {cmd = 0x82d4a34 \"status\", \n    fn = 0x809a6e5 <cmd_status>, option = 5}, {cmd = 0x82d4a3b \"stripspace\", fn = 0x815e3e7 <cmd_stripspace>, \n    option = 0}, {cmd = 0x82d4a46 \"symbolic-ref\", fn = 0x815e849 <cmd_symbolic_ref>, option = 1}, {\n    cmd = 0x82d4a53 \"tag\", fn = 0x816180b <cmd_tag>, option = 1}, {cmd = 0x82d4a57 \"tar-tree\", \n    fn = 0x81630ac <cmd_tar_tree>, option = 0}, {cmd = 0x82d4a60 \"unpack-objects\", \n    fn = 0x8166bdf <cmd_unpack_objects>, option = 1}, {cmd = 0x82d4a6f \"update-index\", \n    fn = 0x816b514 <cmd_update_index>, option = 1}, {cmd = 0x82d4a7c \"update-ref\", fn = 0x816ddd0 <cmd_update_ref>, \n    option = 1}, {cmd = 0x82d4a87 \"update-server-info\", fn = 0x816e734 <cmd_update_server_info>, option = 1}, {\n    cmd = 0x82d4a9a \"upload-archive\", fn = 0x816f579 <cmd_upload_archive>, option = 0}, {\n    cmd = 0x82d4aa9 \"verify-tag\", fn = 0x817257a <cmd_verify_tag>, option = 1}, {cmd = 0x82d4ab4 \"version\", \n    fn = 0x81f5c18 <cmd_version>, option = 0}, {cmd = 0x82d4abc \"whatchanged\", fn = 0x80e339b <cmd_whatchanged>, \n    option = 3}, {cmd = 0x82d4ac8 \"write-tree\", fn = 0x8172814 <cmd_write_tree>, option = 1}, {\n    cmd = 0x82d4ad3 \"verify-pack\", fn = 0x81714a2 <cmd_verify_pack>, option = 0}, {cmd = 0x82d4adf \"show-ref\", \n    fn = 0x815d8b1 <cmd_show_ref>, option = 1}, {cmd = 0x82d4ae8 \"pack-refs\", fn = 0x811f8a4 <cmd_pack_refs>, \n    option = 1}}\n ext = \"\"\n#5  0x0804d1ce in run_argv (argcp=0xbfabea20, argv=0xbfabea24) at git.c:436\n done_alias = 0\n#6  0x0804d6d1 in main (argc=2, argv=0xbfabeaa8) at git.c:507\n cmd = 0xbfac098a \"rerere\"\n done_help = 0\n was_alias = 0\n(gdb) quit"},{"id":"129171","messageId":"20091204103557.GC27495@coredump.intra.peff.net","threadId":"21842","inReplyTo":"D6F784B72498304C93A8A4691967698E8EE2C44FE2@REX2.intranet.epfl.ch","subject":"Re: [BUG] crash on make test","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-04T10:35:57Z","receivedAt":"2009-12-04T10:35:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 03, 2009 at 04:38:58PM +0100, Marinescu Paul dan wrote:\n\n> I got a crash on git's make test with and a core file in ./t/trash\n> directory.t4200-rerere/ The problem seems to be in garbage_collect\n> (builtin-rerere.c) where readdir can be called with a null pointer\n\nHmm. The problematic code is pretty straightforward to see, but what I\ndon't understand is how you managed to trigger it. The code path to get\nthere makes sure that the rr-cache directory exists (because we check\nwhether rerere is enabled, which means either rr-cache exists, or\nrerere.enabled is set, and in the latter case we mkdir the directory).\n\nI can see how it might happen if rr-cache exists but isn't readable. I\ncan easily trigger a segfault with:\n\n  mkdir .git/rr-cache\n  sudo chown root .git/rr-cache\n  sudo chmod 0700 .git/rr-cache\n  git gc\n\nand we should definitely fix that (patch below).\n\nBut how do you end up with this situation in the middle of the test\nsuite? And if it is not a permissions problem, but that the directory is\nmissing, that would indicate something randomly deleting files while\nyou're running the test.\n\nI think we should apply the patch below to maint, as this is something\nthat can come up due to permissions problems. But I fear it won't\nactually fix the test failure you are seeing; you will just see it die()\ninstead of segfaulting. However, the value of errno should give us a\nclue about what is happening, so please try running the test again with\nthis patch.\n\n-- >8 --\nSubject: [PATCH] rerere: don't segfault on failure to open rr-cache\n\nThe rr-cache directory should always exist if we are doing\ngarbage collection (earlier code paths check this\nexplicitly), but we may not necessarily succeed in opening\nit (for example, due to permissions problems). In that case,\nwe should print an error message rather than simply\nsegfaulting.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-rerere.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 343d6cd..2be9ffb 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -48,6 +48,8 @@ static void garbage_collect(struct string_list *rr)\n \n \tgit_config(git_rerere_gc_config, NULL);\n \tdir = opendir(git_path(\"rr-cache\"));\n+\tif (!dir)\n+\t\tdie_errno(\"unable to open rr-cache directory\");\n \twhile ((e = readdir(dir))) {\n \t\tif (is_dot_or_dotdot(e->d_name))\n \t\t\tcontinue;\n-- \n1.6.6.rc1.18.ga777f.dirty\n"},{"id":"129216","messageId":"7vvdgmslwr.fsf@alter.siamese.dyndns.org","threadId":"21842","inReplyTo":"20091204103557.GC27495@coredump.intra.peff.net","subject":"Re: [BUG] crash on make test","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-04T17:12:52Z","receivedAt":"2009-12-04T17:12:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think we should apply the patch below to maint, as this is something\n> that can come up due to permissions problems. But I fear it won't\n> actually fix the test failure you are seeing; you will just see it die()\n> instead of segfaulting. However, the value of errno should give us a\n> clue about what is happening, so please try running the test again with\n> this patch.\n\nThanks, and I agree with the whole of the above paragraph, not just the\nfirst sentence.\n"}]}