https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81829

            Bug ID: 81829
           Summary: [7 Regression] /usr/bin/gcc-{ar,nm,ranlib} segfault
                    without arguments
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org
  Target Milestone: ---

[forwarded from http://bugs.debian.org/853537]

[7 Regression] /usr/bin/gcc-{ar,nm,ranlib} segfault without arguments when call
with an absolute name:

$ gdb --args /usr/bin/gcc-ar

Program received signal SIGSEGV, Segmentation fault.
__strcpy_sse2_unaligned () at
../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296     ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or
directory.
(gdb) bt
#0  __strcpy_sse2_unaligned () at
../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
#1  0x0000000000401a17 in find_a_file (pprefix=0x6061d0 <path>, name=0x4044e6
"ar", mode=1)
    at ../../src/gcc/file-find.c:81
#2  0x00000000004016ee in main (ac=1, av=0x7fffffffe598) at
../../src/gcc/gcc-ar.c:205
(gdb) up
#1  0x0000000000401a17 in find_a_file (pprefix=0x6061d0 <path>, name=0x4044e6
"ar", mode=1)
    at ../../src/gcc/file-find.c:81
81              strcpy (temp, pl->prefix);
(gdb) 

pl->prefix is NULL, set by remove_prefix

remove_prefix at the start has:

Breakpoint 1, remove_prefix (prefix=0x6070d0 "/usr/bin/", pprefix=0x6061d0
<path>)
    at ../../src/gcc/file-find.c:215
215       struct prefix_list *remove, **prev, **remove_prev = NULL;
(gdb) p *pprefix
$1 = {plist = 0x6070b0, max_len = 22, name = 0x0}
(gdb) p *pprefix->plist
$2 = {prefix = 0x607100 "/home/doko/bin/", next = 0x607120}
(gdb) p *pprefix->plist->next
$3 = {prefix = 0x607140 "/home/doko/.local/bin/", next = 0x607340}
(gdb) p *pprefix->plist->next->next
$4 = {prefix = 0x607360 "/usr/local/bin/", next = 0x607380}
(gdb) p *pprefix->plist->next->next->next
$5 = {prefix = 0x6073a0 "/usr/bin/", next = 0x6073c0}
(gdb) p *pprefix->plist->next->next->next->next
$6 = {prefix = 0x6073e0 "/bin/", next = 0x607400}
(gdb) p *pprefix->plist->next->next->next->next->next
$7 = {prefix = 0x607420 "/usr/local/games/", next = 0x607440}
(gdb) p *pprefix->plist->next->next->next->next->next->next
$8 = {prefix = 0x607460 "/usr/games/", next = 0x0}

and then at the end:

(gdb) p *remove_prev
$1 = (prefix_list *) 0x6073c0
(gdb) p **remove_prev
$2 = {prefix = 0x6073e0 "/bin/", next = 0x607400}

(gdb) p *pprefix->plist
$3 = {prefix = 0x607100 "/home/doko/bin/", next = 0x607120}
(gdb) p *pprefix->plist->next
$4 = {prefix = 0x607140 "/home/doko/.local/bin/", next = 0x607340}
(gdb) p *pprefix->plist->next->next
$5 = {prefix = 0x607360 "/usr/local/bin/", next = 0x607380}
(gdb) p *pprefix->plist->next->next->next
$6 = {prefix = 0x0, next = 0x6073c0}
(gdb) p *pprefix->plist->next->next->next->next
$7 = {prefix = 0x6073e0 "/bin/", next = 0x607400}
(gdb) p *pprefix->plist->next->next->next->next->next
$8 = {prefix = 0x607420 "/usr/local/games/", next = 0x607440}
(gdb) p *pprefix->plist->next->next->next->next->next->next
$9 = {prefix = 0x607460 "/usr/games/", next = 0x0}

looks like the next var of the previous entry is not correctly set.

Reply via email to