bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [7.1] texi2any crashes with Bus Error on SPARC


From: Gavin Smith
Subject: Re: [7.1] texi2any crashes with Bus Error on SPARC
Date: Sat, 4 Nov 2023 10:44:04 +0000

On Wed, Nov 01, 2023 at 03:44:01PM +0000, Sam James wrote:
> I thought I'd take a quick look at this. When I tried building with
> -fsanitize=undefined on amd64, unfortunately, I hit another issue
> immediately (with export UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1)::
> 
> util.c:380:3: runtime error: null pointer passed as argument 2, which is 
> declared to never be null
>     #0 0x5629810d4196 in text_buffer_add_string 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/util.c:380
>     #1 0x562981119148 in write_tag_contents 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/scan.c:934
>     #2 0x562981119148 in scan_info_tag 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/scan.c:1441
>     #3 0x562981119148 in scan_node_contents 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/scan.c:1634
>     #4 0x562981110cd2 in info_node_of_tag_ext 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/nodes.c:1289
>     #5 0x5629810f34ec in info_indices_of_file_buffer 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/indices.c:161
>     #6 0x5629810f6333 in look_in_indices 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/indices.c:514
>     #7 0x5629810d7e0c in add_initial_nodes 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/info.c:521
>     #8 0x5629810d7e0c in main 
> /var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/info.c:1048
>     #9 0x7f3996a4b2e6  (/usr/lib64/libc.so.6+0x242e6)
>     #10 0x7f3996a4b3a8 in __libc_start_main (/usr/lib64/libc.so.6+0x243a8)
>     #11 0x5629810d8e04 in _start 
> (/var/tmp/portage/sys-apps/texinfo-7.1/work/texinfo-7.1/info/ginfo+0xde04)
> 
> which led to almost every test failing. Trying -fsanitize=alignment
> (which is a subset of =undefined) didn't give me any issues though,
> interestingly. But I didn't try it on other arches yet or poke into the
> matter further.

I think I've fixed this with the following:

diff --git a/ChangeLog b/ChangeLog
index 34596b8f70..1987470ed5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-11-04  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * info/scan.c (write_tag_contents): Check if added text is of
+       zero length in order to avoid subsequently calling memcpy with
+       a null source argument.  Report with -fsanitize=undefined on amd64
+       from Sam James <sam@gentoo.org>.
+
 2023-11-03  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/XS/Makefile.am: Make files depend on
diff --git a/info/scan.c b/info/scan.c
index d6183ae9ae..bdf272f9bf 100644
--- a/info/scan.c
+++ b/info/scan.c
@@ -925,11 +925,11 @@ write_extra_bytes_to_output (char *input, long n)
 }
 
 /* Like write_extra_bytes_to_output, but writes bytes even when
-   preprocess_nodes=Off. */
+   preprocess_nodes=Off.  Note n could be 0 for an index tag. */
 static void
 write_tag_contents (char *input, long n)
 {
-  if (rewrite_p)
+  if (rewrite_p && n > 0)
     {
       text_buffer_add_string (&output_buf, input, n);
       output_bytes_difference -= n;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]