public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't crash on DWARF5 .debug_line table with zero files.
@ 2021-01-22 12:40 Mark Wielaard
  2021-01-22 12:41 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2021-01-22 12:40 UTC (permalink / raw)
  To: dwz; +Cc: Mark Wielaard

Not having any files in a DWARF5 .debug_line table is odd, but not
technically invalid. Normally there should be a zero file entry that
is equal to the compile unit main file (there is no such zero entry
for early DWARF versions and we handle no file entries fine in that
case).

https://bugzilla.redhat.com/show_bug.cgi?id=1919243
---
 dwz.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dwz.c b/dwz.c
index 53b9548..28f0c4d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -1839,7 +1839,8 @@ read_debug_line (DSO *dso, dw_cu_ref cu, uint32_t off)
 	}
 
       nfiles = read_uleb128 (ptr);
-      nfiles--; /* We will skip the first (zero) entry.  */
+      if (nfiles > 0)
+       nfiles--; /* We will skip the first (zero) entry.  */
     }
 
   cu->cu_nfiles = nfiles;
-- 
2.18.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Don't crash on DWARF5 .debug_line table with zero files.
  2021-01-22 12:40 [PATCH] Don't crash on DWARF5 .debug_line table with zero files Mark Wielaard
@ 2021-01-22 12:41 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2021-01-22 12:41 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: dwz

On Fri, Jan 22, 2021 at 01:40:47PM +0100, Mark Wielaard wrote:
> Not having any files in a DWARF5 .debug_line table is odd, but not
> technically invalid. Normally there should be a zero file entry that
> is equal to the compile unit main file (there is no such zero entry
> for early DWARF versions and we handle no file entries fine in that
> case).
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1919243

Ok.

> ---
>  dwz.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/dwz.c b/dwz.c
> index 53b9548..28f0c4d 100644
> --- a/dwz.c
> +++ b/dwz.c
> @@ -1839,7 +1839,8 @@ read_debug_line (DSO *dso, dw_cu_ref cu, uint32_t off)
>  	}
>  
>        nfiles = read_uleb128 (ptr);
> -      nfiles--; /* We will skip the first (zero) entry.  */
> +      if (nfiles > 0)
> +       nfiles--; /* We will skip the first (zero) entry.  */
>      }
>  
>    cu->cu_nfiles = nfiles;
> -- 
> 2.18.4

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-22 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 12:40 [PATCH] Don't crash on DWARF5 .debug_line table with zero files Mark Wielaard
2021-01-22 12:41 ` Jakub Jelinek

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 read-only IMAP folder(s) and NNTP newsgroup(s).