This is an archive of the discontinued LLVM Phabricator instance.

ignore -mconstructor-aliases when adding field paddings for asan
ClosedPublic

Authored by kcc on Oct 30 2014, 1:26 PM.

Details

Summary

When we are adding field paddings for asan even an empty dtor has to remain in the code,
so we ignore -mconstructor-aliases if the paddings are going to be added.

Diff Detail

Event Timeline

kcc updated this revision to Diff 15577.Oct 30 2014, 1:26 PM
kcc retitled this revision from to ignore -mconstructor-aliases when adding field paddings for asan.
kcc updated this object.
kcc edited the test plan for this revision. (Show Details)
kcc added a reviewer: rsmith.
kcc added a subscriber: Unknown Object (MLST).
rnk edited edge metadata.

Rafael was touching this last.

Why do we have to avoid aliasing? Note that there are many "aliasing" strategies here: RAUW, normal alias, and aliases in D5 comdat groups.

kcc added a comment.Oct 30 2014, 1:54 PM

We need to emit the actual DTOR instead of replacing it with the base class DTOR, because later in clang codegen this DTOR will be instrumented with __asan_unpoison_intra_object_redzone and its body will become non-empty

rnk added a comment.Oct 30 2014, 3:08 PM

No, even if the target dtor is implemented the derived class will have
extra padding it needs to unpoison. Consider:

struct A {

virtual ~A();
int x[1];
int y[1];

};
struct B {

virtual ~B();
int z[1];
int w[1];

};
B::~B() {}

The B dtor must unpoison the padding between z and w.

rafael accepted this revision.Oct 31 2014, 9:21 AM
rafael edited edge metadata.

LGTM with rnk's example and explanation added to a testcase.

This revision is now accepted and ready to land.Oct 31 2014, 9:21 AM
kcc closed this revision.Oct 31 2014, 12:11 PM