public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type
@ 2023-01-25  1:21 raj.khem at gmail dot com
  2023-01-25  1:30 ` [Bug libdw/30047] " raj.khem at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: raj.khem at gmail dot com @ 2023-01-25  1:21 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

            Bug ID: 30047
           Summary: libdw unable to handle DW_TAG_unspecified_type
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libdw
          Assignee: unassigned at sourceware dot org
          Reporter: raj.khem at gmail dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

GNU assembler starting with 2.40 release is generating DW_TAG_unspecified_type
for assembly files [1] this is fixed in gdb [2], however, it shows up as one of
test failures in elfutils 


% ./funcretval
() _start: ./funcretval: dwfl_module_return_value_location: cannot handle DWARF
type description

The reason is that glibc startup files e.g. (/usr/lib/Scrt1.o) is built from
assembly routines and when compiled with toolchain using binutils 2.40 gets
these DW_TAG_unspecified_type entries emitted into its debug segments which
inturn get into the testcases when they are built in elfutils testsuites

native.c
=========
#include <unistd.h>
int main () { while (1) pause (); return 0;}

gcc -g native.c

./funcretval

then results in this error and failure in elfutils testcases

/usr/lib/elfutils/ptest/tests/funcretval: dwfl_module_return_value_location:
cannot handle DWARF type description
FAIL: run-native-test.sh

I think libdw has to implement handling DW_TAG_unspecified_type, since it will
start showing up everywhere soon as 2.40 binutils trickle into downstream
distributions and they do mass-rebuilds.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29559
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=29558

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
@ 2023-01-25  1:30 ` raj.khem at gmail dot com
  2023-01-26 16:39 ` mark at klomp dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: raj.khem at gmail dot com @ 2023-01-25  1:30 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

--- Comment #1 from Khem Raj <raj.khem at gmail dot com> ---
Created attachment 14620
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14620&action=edit
sample binary linked with glibc built with binutils 2.40

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
  2023-01-25  1:30 ` [Bug libdw/30047] " raj.khem at gmail dot com
@ 2023-01-26 16:39 ` mark at klomp dot org
  2023-01-26 17:30 ` mark at klomp dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mark at klomp dot org @ 2023-01-26 16:39 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
This is slightly tricky, because I think we technically do the right thing
here.

dwfl_module_return_value_location returns that cannot handle DWARF type
description error, which is technically correct, since it is an
unspecified_type.

dwfl_module_return_value_location can return an error (< 0) which means either
bad DWARF or unknown/unhandled type, it can return zero, which means the
function has no return value, or it return the number of DWARF expression
operations (> 0) that describe how to get the value returned by the function.

Sadly we don't have an easy way to distinguish between bad DWARF/type and
cannot handle type.

I think we can change the testcase though, to check for the special case of
DW_TAG_unspecified_type.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
  2023-01-25  1:30 ` [Bug libdw/30047] " raj.khem at gmail dot com
  2023-01-26 16:39 ` mark at klomp dot org
@ 2023-01-26 17:30 ` mark at klomp dot org
  2023-01-26 17:41 ` raj.khem at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mark at klomp dot org @ 2023-01-26 17:30 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-01-26
           Assignee|unassigned at sourceware dot org   |mark at klomp dot org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
Created attachment 14633
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14633&action=edit
tests: Handle DW_TAG_unspecified_type in funcretval test

This patch just fixes the testcase to check for DW_TAG_unspecified_type as
return type.
With your test binary tests/funcretval now prints:

() _start: returns unspecified type
() main: return value location: {0x50, 0}

But maybe a better fix is for dwfl_module_return_value_location to return zero
(which technically means that the function doesn't have a return value).

Opinions?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (2 preceding siblings ...)
  2023-01-26 17:30 ` mark at klomp dot org
@ 2023-01-26 17:41 ` raj.khem at gmail dot com
  2023-02-06 13:11 ` mliska at suse dot cz
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: raj.khem at gmail dot com @ 2023-01-26 17:41 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

--- Comment #4 from Khem Raj <raj.khem at gmail dot com> ---
lgtm, I did something similar by changing return value locally.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (3 preceding siblings ...)
  2023-01-26 17:41 ` raj.khem at gmail dot com
@ 2023-02-06 13:11 ` mliska at suse dot cz
  2023-02-07 15:47 ` mark at klomp dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mliska at suse dot cz @ 2023-02-06 13:11 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

--- Comment #5 from Martin Liska <mliska at suse dot cz> ---
May I please ping this issue as one needs it with the latest binutils release
(2.40).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (4 preceding siblings ...)
  2023-02-06 13:11 ` mliska at suse dot cz
@ 2023-02-07 15:47 ` mark at klomp dot org
  2023-02-14  8:25 ` mliska at suse dot cz
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mark at klomp dot org @ 2023-02-07 15:47 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #14633|0                           |1
        is obsolete|                            |

--- Comment #6 from Mark Wielaard <mark at klomp dot org> ---
Created attachment 14657
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14657&action=edit
backends: Handle DW_TAG_unspecified_type in dwarf_peeled_die_type

(In reply to Martin Liska from comment #5)
> May I please ping this issue as one needs it with the latest binutils
> release (2.40).

Yes, thanks. I didn't forget, but I changed my mind how to best handle this
issue.
See the new patch. This changes the code so that an DW_TAG_unspecified_type is
treated just as if the function doesn't have a return type. I think that is a
better fix because there might be more code out there that uses
dwfl_module_return_value_location and might not handle an error in this case.
And there isn't actually much that can be done with an unspecified type, for
normal cases it is as if there is no return type.

I did adjust the testcase to show how you can see whether it is a missing
return type or an unspecified return type in case you program does care.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (5 preceding siblings ...)
  2023-02-07 15:47 ` mark at klomp dot org
@ 2023-02-14  8:25 ` mliska at suse dot cz
  2023-02-14 15:34 ` mark at klomp dot org
  2023-03-02 13:27 ` mliska at suse dot cz
  8 siblings, 0 replies; 10+ messages in thread
From: mliska at suse dot cz @ 2023-02-14  8:25 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

--- Comment #7 from Martin Liska <mliska at suse dot cz> ---
Thank you, Mark. Can you please commit the patch so that very can cherry-pick
it?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (6 preceding siblings ...)
  2023-02-14  8:25 ` mliska at suse dot cz
@ 2023-02-14 15:34 ` mark at klomp dot org
  2023-03-02 13:27 ` mliska at suse dot cz
  8 siblings, 0 replies; 10+ messages in thread
From: mark at klomp dot org @ 2023-02-14 15:34 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Mark Wielaard <mark at klomp dot org> ---
commit f2c522567ad63ac293535fba9704895e685ab5bc
Author: Mark Wielaard <mark@klomp.org>
Date:   Thu Jan 26 18:19:15 2023 +0100

    backends: Handle DW_TAG_unspecified_type in dwarf_peeled_die_type

    binutils 2.40 introduces DW_TAG_unspecified_type for assembly
    functions with an unknown return type. This breaks the
    run-funcretval.sh testcase because dwfl_module_return_value_location
    returns an error for such functions because it cannot determine the
    return value location. Fix that by treating DW_TAG_unspecified_type
    as if the DIE doesn't have a DW_AT_type.

    Also update the testcase to explicitly checking for
    DW_TAG_unspecified_type and printing "returns unspecified type".

    https://sourceware.org/bugzilla/show_bug.cgi?id=30047

    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libdw/30047] libdw unable to handle DW_TAG_unspecified_type
  2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
                   ` (7 preceding siblings ...)
  2023-02-14 15:34 ` mark at klomp dot org
@ 2023-03-02 13:27 ` mliska at suse dot cz
  8 siblings, 0 replies; 10+ messages in thread
From: mliska at suse dot cz @ 2023-03-02 13:27 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=30047

Martin Liska <mliska at suse dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kloczko.tomasz at gmail dot com

--- Comment #9 from Martin Liska <mliska at suse dot cz> ---
*** Bug 30192 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2023-03-02 13:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25  1:21 [Bug libdw/30047] New: libdw unable to handle DW_TAG_unspecified_type raj.khem at gmail dot com
2023-01-25  1:30 ` [Bug libdw/30047] " raj.khem at gmail dot com
2023-01-26 16:39 ` mark at klomp dot org
2023-01-26 17:30 ` mark at klomp dot org
2023-01-26 17:41 ` raj.khem at gmail dot com
2023-02-06 13:11 ` mliska at suse dot cz
2023-02-07 15:47 ` mark at klomp dot org
2023-02-14  8:25 ` mliska at suse dot cz
2023-02-14 15:34 ` mark at klomp dot org
2023-03-02 13:27 ` mliska at suse dot cz

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).