[llvm-bugs] [Bug 32761] New: [coverage][windows] Null pointer dereference in CodeGenPGO::skipRegionMappingForDecl

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 23 13:27:49 PDT 2017


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

            Bug ID: 32761
           Summary: [coverage][windows] Null pointer dereference in
                    CodeGenPGO::skipRegionMappingForDecl
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: adamf88 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18334
  --> https://bugs.llvm.org/attachment.cgi?id=18334&action=edit
Test + My fix.

In function CodeGenPGO::skipRegionMappingForDecl there is possible NULL pointer
dereference on line:
auto Loc = D->getBody()->getLocStart();
Value returned by getBody may be nullptr. 

(minor)
The variable SkipCoverageMapping in the same function has always value false.
Shouldn't it be removed ?

In attachment I have added my sample fix and test to reproduce the bug. In the
patch I have also removed the variable mentioned above. 
To fix this issue check: "if(!D->hasBody()) return true;" should be enough.

Sample code to reproduce the problem:
class A
{
public:
  A();
  virtual ~A();
};

class B : public A
{
public:
  B(const A& base)
    : A(base)
  {}
};

void Test()
{
  A a;
  B b(a);
}

Compile command:
clang++ -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj
-fprofile-instrument=clang -std=c++14 -fcoverage-mapping -dump-coverage-mapping
-emit-llvm-only -main-file-name empty-destructor.cpp -o - empty-destructor.cpp

Effect:
Crash.

-- 
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/20170423/afd39fb1/attachment.html>


More information about the llvm-bugs mailing list