[llvm-bugs] [Bug 31843] New: Clang-4.0 crashes/assert while evaluating __builtin_object_size: "APValues can't handle invalid LValue bases"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 1 15:49:26 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31843

            Bug ID: 31843
           Summary: Clang-4.0 crashes/assert while evaluating
                    __builtin_object_size:  "APValues can't handle invalid
                    LValue bases"
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mehdi.amini at apple.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Simple reproduction (build as C file):


struct statfs { char f_mntonname[1024];};
fn1() {
  struct statfs *outStatFSBuf;
  __builtin_object_size (outStatFSBuf->f_mntonname ? outStatFSBuf : "", 2 > 1 ?
1 : 0);
}


AFAICT what happens is that in:

  static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {


we're doing:

  } else if (T->hasPointerRepresentation()) {
    LValue LV;
    if (!EvaluatePointer(E, LV, Info))
      return false;
    LV.moveInto(Result);


The issue is that `Info.allowInvalidBaseExpr()` is true, so `EvaluatePointer`
returns true even though the Base is marked as invalid in the result `LV`.
We then assert in the call  `LV.moveInto(Result);`   "APValues can't handle
invalid LValue bases"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170201/f8bc5142/attachment.html>


More information about the llvm-bugs mailing list