Bug 308027 - Warning: negative range in .debug_loc section
Summary: Warning: negative range in .debug_loc section
Status: RESOLVED NOT A BUG
Alias: None
Product: valgrind
Classification: Developer tools
Component: sgcheck (show other bugs)
Version: 3.9.0.SVN
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-07 14:15 UTC by alexanderm.08
Modified: 2023-11-17 00:17 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Verbose log of valgrind (16.10 KB, text/plain)
2012-10-07 14:17 UTC, alexanderm.08
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alexanderm.08 2012-10-07 14:15:34 UTC
On startup with sgcheck the current svn HEAD version (revision 13027) 

WARNING: Serious error when reading debug info
--18990-- When reading debug info from /home/alexander/src/cppcheck/head/cppcheck:
--18990-- negative range in .debug_loc section
--18990-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--18990-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--18990-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--18990-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93

While the latter seems to be a known issue (Bug 185801 ,etc) I could not see the first warning mentioned here as well.



Reproducible: Always

Steps to Reproduce:
1. Just launch the tool on the given executable
2.
3.
Actual Results:  
The tool seems to work afterwards, or more precisely: no additional warning or error messages appear.

Expected Results:  
Do not issue warning ;-)

The executable was built on OpenSuse 12.1 using g++ 4.6.2.
ldd says:
        linux-vdso.so.1 =>  (0x00007fff7efff000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f0d210ea000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f0d20e93000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f0d20c7d000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f0d208ed000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0d213f4000)
Comment 1 alexanderm.08 2012-10-07 14:17:32 UTC
Created attachment 74387 [details]
Verbose log of valgrind

-v output of valgrind for the given example.
Comment 2 Christian Borntraeger 2012-10-08 07:14:55 UTC
I had the same some time ago on s390. It was a gcc bug back then:
e.g. http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01219.html

Your gcc seems newer. Anyway valgrind should probably just continue instead of ignoring the other debug info. This hack would disable the warning and continue to use the exisiting debug information.

Index: valgrind-3.6/coregrind/m_debuginfo/readdwarf3.c
===================================================================
--- valgrind-3.6.orig/coregrind/m_debuginfo/readdwarf3.c
+++ valgrind-3.6/coregrind/m_debuginfo/readdwarf3.c
@@ -590,12 +590,13 @@ static GExpr* make_general_GX ( CUConst*
       /* else enumerate [w1+base, w2+base) */
       /* w2 is 1 past end of range, as per D3 defn for "DW_AT_high_pc"
          (sec 2.17.2) */
-      if (w1 > w2) {
+// this happens with some gcc versions.
+/*      if (w1 > w2) {
          TRACE_D3("negative range is for .debug_loc expr at "
                   "file offset %lu\n", 
                   debug_loc_offset);
          cc->barf( "negative range in .debug_loc section" );
-      }
+      }*/ 
 
       /* ignore zero length ranges */
       acquire = w1 < w2;
Comment 3 alexanderm.08 2012-10-13 17:31:51 UTC
Well, I've found the gcc bug tracked on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45939

Seems, the analysis "The problem could not be reproduced with head" (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45939#c2) was wrong - given head was older than my 4.6.2.
Maybe I should re-open that bug or file a follow-up.
Comment 4 Christian Borntraeger 2012-10-15 06:37:15 UTC
It is very likely a different bug, so please double check the debugloc section with readelf and open a new bug against gcc if appropriate.
Comment 5 Julian Seward 2013-03-01 11:58:37 UTC
I'm confused.  Do we need to do anything about this for V 3.9, or can 
this bug be closed now?
Comment 6 Christoph Feck 2013-04-16 12:56:29 UTC
If you can provide the information requested in comment #5, please add it.
Comment 7 Mark Wielaard 2023-11-17 00:17:24 UTC
The exp-sgcheck tool isn't part of valgrind anymore and the warning was correct, it was a gcc bug.