Bug 388493

Summary: exp-sgcheck fails on DW_TAG_subrange_type
Product: [Developer tools] valgrind Reporter: BartÅ‚omiej Piotrowski <bpiotrowski>
Component: sgcheckAssignee: Julian Seward <jseward>
Status: RESOLVED UNMAINTAINED    
Severity: crash CC: bpiotrowski, ivosh, pjfloyd, tom
Priority: NOR    
Version: 3.13.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Bartłomiej Piotrowski 2018-01-03 13:43:56 UTC
I'm trying to debug a problem reported by our user[1]. If ELF is linked against libgfortran, and libgfortran did not have debugging symbols stripped, exp-sgcheck fails on parsing it: https://paste.xinu.at/ChI/

Stripped libgfortran only hides the error, although output is still rather useless: https://paste.xinu.at/6qg/

Any tips how to proceed with that to produce something more useful to you?

Simple "hello world" built with -g and -lgfortran using gcc 7.2.1+20171224 is enough to reproduce the problem.

[1] https://bugs.archlinux.org/task/56294
Comment 1 Tom Hughes 2018-01-03 14:16:58 UTC
My tip would be to include the error message in this bug report instead of hiding it away on a third party pastebin...
Comment 2 Tom Hughes 2018-01-03 14:19:39 UTC
To be honest I think here are probably two entirely separate issues. One is the DWARF parser not handling the subrange tag:

parse DIE(readdwarf3.c:3619): confused by:
 <2><17a1ec>: Abbrev Number: 10 (DW_TAG_subrange_type)
     DW_AT_type        : <17a20a>	
     DW_AT_upper_bound : <17a188>	
parse_type_DIE:
--2028-- WARNING: Serious error when reading debug info
--2028-- When reading debug info from /usr/lib/libgfortran.so.4.0.0:
--2028-- confused by the above DIE

That goes away in the stripped version simply because it no longer has any DWARF information to be parsed!

The second is an instrumentation failure in the exp-sgcheck tool:

exp-sgcheck: sg_main.c:2332 (sg_instrument_IRStmt): the 'impossible' happened.

It's probably best to open a separate bug for that.
Comment 3 Ivo Raisr 2018-01-03 18:15:16 UTC
The DWARF problem is highly probably caused by an unimplemented functionality in parse_type_DIE(). For DW_tag_subrange, the following is handled:

      /* Figure out if we have a definite range or not */
      if (have_lower && have_upper && (!have_count)) {
         boundE.Te.Bound.knownL = True;
         boundE.Te.Bound.knownU = True;
         boundE.Te.Bound.boundL = lower;
         boundE.Te.Bound.boundU = upper;
      }
      else if (have_lower && (!have_upper) && (!have_count)) {
         boundE.Te.Bound.knownL = True;
         boundE.Te.Bound.knownU = False;
         boundE.Te.Bound.boundL = lower;
         boundE.Te.Bound.boundU = 0;
      }
      else if ((!have_lower) && have_upper && (!have_count)) {
         boundE.Te.Bound.knownL = False;
         boundE.Te.Bound.knownU = True;
         boundE.Te.Bound.boundL = 0;
         boundE.Te.Bound.boundU = upper;
      }
      else if ((!have_lower) && (!have_upper) && (!have_count)) {
         boundE.Te.Bound.knownL = False;
         boundE.Te.Bound.knownU = False;
         boundE.Te.Bound.boundL = 0;
         boundE.Te.Bound.boundU = 0;
      } else {
         /* FIXME: handle more cases */
         goto_bad_DIE;
      }

So probably implementing the missing case would overcome the reported DWARF problem.
Comment 4 Paul Floyd 2020-10-28 11:14:38 UTC
2nd thoughts, this looks like a debug info issue
Comment 5 Paul Floyd 2022-09-29 15:12:39 UTC
exp-sgcheck has been removed.