[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gtags SEGFAULTS on RPi 3 Raspbian (buster)
From: |
Shigio YAMAGUCHI |
Subject: |
Re: gtags SEGFAULTS on RPi 3 Raspbian (buster) |
Date: |
Wed, 4 Aug 2021 16:24:15 +0900 |
Hello,
I fixed it in a slightly different way.
The fix will be included in the next release.
Thank you for the bug report!
Regards,
Shigio
Index: libutil/find.c
===================================================================
RCS file: /sources/global/global/libutil/find.c,v
retrieving revision 1.118
diff -c -r1.118 find.c
*** libutil/find.c 22 Sep 2020 01:40:42 -0000 1.118
--- libutil/find.c 4 Aug 2021 07:14:02 -0000
***************
*** 781,787 ****
find_read_filelist(void)
{
STATIC_STRBUF(ib);
! static char buf[MAXPATHLEN + 1];
static char *path;
strbuf_clear(ib);
--- 781,800 ----
find_read_filelist(void)
{
STATIC_STRBUF(ib);
! /*
! * The buf has room for one character ' ' in front.
! *
! * __buf
! * +---+---+---+---+ +---+
! * |' '| | | ..... |
! * +---+---+---+---+ +---+
! * ^
! * buf
! * <--- bufsize --->
! */
! static char __buf[MAXPATHLEN + 2];
! static char *buf = &__buf[1];
! static int bufsize = sizeof(__buf) - 1;
static char *path;
strbuf_clear(ib);
***************
*** 820,826 ****
* rootdir /a/b/
* buf /a/b/c/d.c -> c/d.c -> ./c/d.c
*/
! if (normalize(path, rootdir, cwddir, buf, sizeof(buf)) == NULL) {
warning("'%s' is out of source tree. ignored.", trimpath(path));
continue;
}
--- 833,839 ----
* rootdir /a/b/
* buf /a/b/c/d.c -> c/d.c -> ./c/d.c
*/
! if (normalize(path, rootdir, cwddir, buf, bufsize) == NULL) {
warning("'%s' is out of source tree. ignored.", trimpath(path));
continue;
}
On Tue, Aug 3, 2021 at 10:47 PM Jim Lowe <jhl@infionline.net> wrote:
>
> gtags, (on Raspberry Pi 3 Raspbian buster using the stock gcc) with an
> invocation similar to
>
> gtags -i /tmp/xx/ -f /tmp/xxlist.txt
>
> segfaulted on the line in libutil/find.c
>
> *--path = ' ';
>
> Does this step to the left of the static array and assign a value?
> (and the combination on RaspberryPi 3 and Raspian (buster) does not tolerate
> this).
>
> Other platforms seem not to mind this.
>
> A possible fix is shown in the patch below (this fixed the segfault) and
> gtags seemed to work normally.
>
>
> --- global-6.6.7/libutil/find.c 2021-07-01 00:06:35.000000000 -0400
> +++ global-6.6.7jl/libutil/find.c 2021-07-29 21:42:32.349124964 -0400
> @@ -803,45 +803,45 @@
> continue;
> /*
> * Skip the following:
> * o directory
> * o file which does not exist
> * o dead symbolic link
> */
> if (!test("f", path)) {
> if (test("d", path))
> warning("'%s' is a directory. ignored.",
> trimpath(path));
> else
> warning("'%s' not found. ignored.",
> trimpath(path));
> continue;
> }
> /*
> * normalize path name.
> *
> * rootdir /a/b/
> * buf /a/b/c/d.c -> c/d.c -> ./c/d.c
> */
> - if (normalize(path, rootdir, cwddir, buf, sizeof(buf)) ==
> NULL) {
> + if (normalize(path, rootdir, cwddir, buf+1, sizeof(buf)-1) ==
> NULL) {
> warning("'%s' is out of source tree. ignored.",
> trimpath(path));
> continue;
> }
> - path = buf;
> + path = buf+1;
> /*
> * Now GLOBAL can treat the path which includes blanks.
> * This message is obsoleted.
> */
> if (!allow_blank && locatestring(path, " ",
> MATCH_LAST)) {
> warning("'%s' ignored, because it includes blank.",
> trimpath(path));
> continue;
> }
> if (skipthisfile(path))
> continue;
> /*
> * A blank at the head of path means
> * other than source file.
> */
> if (!issourcefile(path))
> /*SEGFAULT HERE >>>> */ *--path = ' ';
> return path;
> }
> }
>
--
Shigio YAMAGUCHI <shigio@gnu.org>
PGP fingerprint:
26F6 31B4 3D62 4A92 7E6F 1C33 969C 3BE3 89DD A6EB