llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Assertion `(!CombinedExpr || CombinedExpr->isValid()) && "Combined debug expression is invalid"' failed

Open dstenb opened this issue 6 years ago • 6 comments

Bugzilla Link 45181
Resolution FIXED
Resolved on Mar 18, 2020 00:59
Version trunk
OS Windows NT
Blocks llvm/llvm-project#43461
CC @dstenb,@djtodoro,@JDevlieghere,@walkerkd,@lalozano,@m-gupta,@pogo59,@vedantk

Extended Description

Found by Manoj Gupta.

https://reviews.llvm.org/D73534#1918890

File:

struct type *a(type *, type *, long, long); enum b {}; static int empty_array(type *, int c) { type *d = a(__null, d, c, c - 1); } long e; b f() { empty_array(0, e); }

Command:

$ clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mframe-pointer=all -mconstructor-aliases -munwind-tables -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O2 -x c++

gives:

clang: /home/edasten/upstream/monorepo/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:630: void addToFwdRegWorklist(FwdRegWorklist&, unsigned int, const llvm::DIExpression*, llvm::ArrayRef): Assertion `CombinedExpr->isValid() && "Combined debug expression is invalid"' failed. Stack dump: 0. Program arguments: ./build/bin/clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mframe-pointer=all -mconstructor-aliases -munwind-tables -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O2 -x c++ combined.c

  1. parser at end of file
  2. Code generation
  3. Running pass 'Function Pass Manager' on module 'combined.c'.
  4. Running pass 'X86 Assembly Printer' on function '@_ZL11empty_arrayP4typei'

The invalid DIExpression is produced by appending together the following two expressions:

Expr: !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_LLVM_convert, 64, DW_ATE_signed, DW_OP_stack_value) Param.Expr: !DIExpression(DW_OP_constu, 1, DW_OP_minus, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_LLVM_convert, 64, DW_ATE_signed, DW_OP_stack_value)

That results in a DW_OP_stack_value being in the middle of a DIExpression, which is invalid.

The DW_OP_stack_values are added to the expressions due to use of DIExpression::appendExt() which in turn uses appendToStack(). I don't think that the describeLoadedValue() hook should return DIExpressions using DW_OP_stack_value, since that will be used to produce DW_AT_call_values, which are implicitly stack operations.

dstenb avatar Mar 12 '20 09:03 dstenb

Thanks, I will re-land the https://reviews.llvm.org/D73534.

djtodoro avatar Mar 18 '20 07:03 djtodoro

This should be fixed in 526c51e.

Great. Thanks!

dstenb avatar Mar 17 '20 21:03 dstenb

This should be fixed in 526c51e.

vedantk avatar Mar 17 '20 20:03 vedantk

This is currently breaking ToT llvm builds in Chrome OS.

m-gupta avatar Mar 12 '20 17:03 m-gupta

Further reduced reproducer:

extern void callee(long, long); void caller(int c) { callee(c, c - 1); }

dstenb avatar Mar 12 '20 11:03 dstenb

The reason for why we're trying to append two convert expressions in the first place is because when trying to describe $eax using:

$eax = LEA64_32r renamable $rdx, 1, $noreg, -1, $noreg

we return ($rdx, DW_OP_constu, 1, DW_OP_minus). I think we want to return the 32-bit sub-register of the source instead.

dstenb avatar Mar 12 '20 10:03 dstenb