Bug 847497

Summary: semantic error: dwarf_getlocation_addr failed, invalid DWARF: identifier...
Product: [Fedora] Fedora Reporter: Roman Rakus <rrakus>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: dsmith, fche, jakub, jan.kratochvil, jistone, law, lberk, mjw, scox, tsmetana, wcohen
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 847510 (view as bug list) Environment:
Last Closed: 2013-08-01 00:59:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 847510    

Description Roman Rakus 2012-08-12 09:19:58 UTC
Description of problem:
Systemtap poorly parses dwarf and says "$SUMMARY".

Version-Release number of selected component (if applicable):
$ rpm -q bash bash-debuginfo systemtap
bash-4.2.37-2.fc17.x86_64
bash-debuginfo-4.2.37-2.fc17.x86_64
systemtap-1.8-4.fc17.x86_64


How reproducible:
100%

Steps to Reproduce:
1. stap -e 'probe process("bash").function("execute_builtin"){print("%p\n", $words)}'
2.
3.
  
Actual results:
$ stap -e 'probe process("bash").function("execute_builtin"){print("%p\n", $words)}'
semantic error: dwarf_getlocation_addr failed, invalid DWARF: identifier '$words' at <input>:1:65
        source: probe process("bash").function("execute_builtin"){print("%p\n", $words)}
                                                                                ^


Expected results:
semantic error: not accessible at this address (?)
The best would be if systemtap says the variable is optimized out, like GDB.

Additional info:

Comment 1 Jan Kratochvil 2012-08-12 10:50:50 UTC
GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -m64 -mtune=generic -march=x86-64 -g -O2 -fexceptions -fstack-protector --param ssp-buffer-size=4

GCC used DW_OP_GNU_parameter_ref at the callee but DW_OP_reg4 (rsi) at the caller.  Caller is inlined function.

(gdb) bt
#0  execute_builtin (..., words=<optimized out>) at execute_cmd.c:4047
#1  0x0000000000431873 in execute_builtin_or_function (words=0x6fb260)
                       at execute_cmd.c:4546
#2  execute_simple_command (...) at execute_cmd.c:3956
(gdb) set debug entry-values 1
(gdb) p words
Cannot find matching parameter at DW_TAG_GNU_call_site 0x431873 at execute_simple_command
$2 = <optimized out>

 <1><1c2c4>: Abbrev Number: 68 (DW_TAG_subprogram)
    <1c2c5>   DW_AT_abstract_origin: <0x1b17a>
         <1><1b17a>: Abbrev Number: 38 (DW_TAG_subprogram)
            <1b17b>   DW_AT_name        : execute_builtin
 <2><1c2fa>: Abbrev Number: 73 (DW_TAG_formal_parameter)
    <1c2fb>   DW_AT_abstract_origin: <0x1b197>
         <2><1b197>: Abbrev Number: 36 (DW_TAG_formal_parameter)
            <1b198>   DW_AT_name        : words
    <1c2ff>   DW_AT_location    : 6 byte block: fa d 18 0 0 9f
                         (DW_OP_GNU_parameter_ref: <0x1b197>; DW_OP_stack_value)
 <4><1eb7f>: Abbrev Number: 55 (DW_TAG_GNU_call_site)
    <1eb80>   DW_AT_low_pc      : 0x431873
 <5><1eb96>: Abbrev Number: 56 (DW_TAG_GNU_call_site_parameter)
    <1eb97>   DW_AT_location    : 1 byte block: 54      (DW_OP_reg4 (rsi))
    <1eb99>   DW_AT_GNU_call_site_value: 2 byte block: 73 0
                                                       (DW_OP_breg3 (rbx): 0)
        = it is really 'words'

Comment 2 Jakub Jelinek 2012-08-14 14:01:01 UTC
Short testcase for -g -O2:

struct A { struct A *a; void *b; };
typedef int FN (struct A *);
extern void *v;

void
foo (struct A *x, FN *y, int z)
{
  baz (x, y, z);
}

static int
bar (FN *x, struct A *y, int z, int w)
{
  if (v)
    undef (8, v);
  (*x) (y->a);
}

int
baz (struct A *x, FN *y, int z)
{
  bar (y, x, z, 0);
  return 0;
}

I don't think this is a GCC bug, the thing is that ISRA changes the argument from struct A * into struct A ** and the y->a read into *ISRA.xxx read.

Comment 3 Jakub Jelinek 2012-08-14 15:19:56 UTC
Even better testcase:

struct A
{
#ifdef PAD
  void *c;
#endif
  struct A *a;
  void *b;
};
typedef int FN (struct A *);
extern void *v;
struct A *fn (void);

void
foo (FN *y, int z)
{
  struct A *x = fn ();
  baz (x, y, z);
}

static int
bar (FN *x, struct A *y, int z, int w)
{
  if (v)
    undef (8, v);
  (*x) (y->a);
}

int
baz (struct A *x, FN *y, int z)
{
  bar (y, x, z, 0);
  return 0;
}

The reason IPA-SRA does this transformation is that it hopes it could then scalarize the structure in the caller.  If it does, then usually there is no way to reconstruct the original argument, if it doesn't, then yes, one could in the callee reconstruct the argument by adding some constant (0 in this case) to the magic ISRA.NNN argument.  But is it worth it?  It could be done only if all callers have the argument not scalarized.

Comment 4 Fedora End Of Life 2013-07-03 22:50:04 UTC
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2013-08-01 00:59:57 UTC
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.