Bug 277045 - Valgrind crashes with unhandled DW_OP_ opcode 0x2a in gcc (Debian 4.6.1-1) 4.6.1 with debian unstable x64
Summary: Valgrind crashes with unhandled DW_OP_ opcode 0x2a in gcc (Debian 4.6.1-1) 4...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.7 SVN
Platform: Unlisted Binaries Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-04 07:23 UTC by Dimitris Zenios
Modified: 2011-07-21 15:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Implement DW_OP_ge and friends (2.92 KB, patch)
2011-07-04 19:25 UTC, Tom Hughes
Details
Implement DWARF comparison and shift operators (3.09 KB, patch)
2011-07-05 09:14 UTC, Tom Hughes
Details
valgrind-relational.patch (934 bytes, patch)
2011-07-21 14:56 UTC, Jakub Jelinek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitris Zenios 2011-07-04 07:23:41 UTC
Version:           3.7 SVN
OS:                Linux

==8348== Memcheck, a memory error detector
==8348== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==8348== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==8348== Command: ./testesassad
==8348== 
--8348-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x2a

valgrind: m_debuginfo/readdwarf.c:2397 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed.
==8348==    at 0x3802CFC6: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=0


Reproducible: Always

Steps to Reproduce:
Just run any program.


Expected Results:  
the program should run
Comment 1 Derick Rethans 2011-07-04 17:09:13 UTC
I am having exactly the same problem after just having upgraded to the new Debian version of valgrind. It seems to happen for all programs as well:

derick@whisky:~/dev/Twig$ valgrind /bin/ls
==6707== Memcheck, a memory error detector
==6707== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==6707== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==6707== Command: /bin/ls
==6707== 
--6707-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x2a

valgrind: m_debuginfo/readdwarf.c:2338 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed.
==6707==    at 0x3802CFF6: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
Comment 2 Derick Rethans 2011-07-04 17:44:17 UTC
I've also added a Debian bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632666
Comment 3 Tom Hughes 2011-07-04 19:25:08 UTC
Created attachment 61606 [details]
Implement DW_OP_ge and friends

I don't know if it will fix the assertion or not, but this patch should implement the missing opcode (which is DW_OP_ge).
Comment 4 Derick Rethans 2011-07-05 08:44:36 UTC
This patch indeed fixes the original error, but I am now getting a new one:

derick@whisky:~$ /home/derick/local/bin/valgrind /bin/ls
==22174== Memcheck, a memory error detector
==22174== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==22174== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==22174== Command: /bin/ls
==22174== 
--22174-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x24

valgrind: m_debuginfo/readdwarf.c:2338 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed.
==22174==    at 0x3804AE36: report_and_quit (m_libcassert.c:193)
Comment 5 Tom Hughes 2011-07-05 09:14:54 UTC
Created attachment 61618 [details]
Implement DWARF comparison and shift operators

Derick sent me the failing object, which was actually one of valgrind's preload libraries in his newly built patched version. It was built with gcc 4.6.1 and the problem seems to be the default CFA expression in one of the FDEs which looks like:

  DW_OP_breg7 (rsp): 8
  DW_OP_breg16 (rip): 0;
  DW_OP_lit15
  DW_OP_and
  DW_OP_lit11
  DW_OP_ge
  DW_OP_lit3
  DW_OP_shl
  DW_OP_plus

Which decodes as:

  if %rip & 0xf >= 11
    cfa = %rsp + 8
  else
    cfa = %rsp

Which is quite funky but anyway the good news it that it looks like DW_OP_shl is the only other thing we need so this new patch adds that (and DW_OP_shr for good measure). I've also fixed the relational ops, which I had back to front due to the DWARF 2 standard being unclear - it has been clarified in the DWARF 3 spec.

Still no idea if it will fix the assertion of course...
Comment 6 Tom Hughes 2011-07-05 09:28:14 UTC
Derick has confirmed the patch fixes the problem so I have committed it as r11856.
Comment 7 Derick Rethans 2011-07-05 09:29:11 UTC
I can confirm that this new patches fixes valgrind for me \o/.
Comment 8 Jakub Jelinek 2011-07-21 14:56:54 UTC
Created attachment 62050 [details]
valgrind-relational.patch

Unfortunately this isn't correct, DW_OP_{ge,gt,le,lt} as per DWARF{2,3,4} perform signed comparisons instead of unsigned.  In the case of the PLT unwind info that triggered this (see
http://sources.redhat.com/ml/binutils/2011-06/msg00225.html
) it doesn't matter as the value is masked and so is always non-negative (and the second operand is constant), but it could matter elsewhere.
BTW, it is strange that shr operation has been added and shra has not (arithmetic right shift).
Comment 9 Tom Hughes 2011-07-21 15:09:22 UTC
It's not really strange when you consider that shr is dead easy to implement in C and shra is much harder ;-)
Comment 10 Tom Hughes 2011-07-21 15:12:20 UTC
Patch committed as r11904.