[PATCH] D22419: [CFG] Fix crash in thread sanitizer.

Nandor Licker via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 09:43:39 PDT 2016


nandor added a comment.

I'm not an expert in temporaries either, I think for a proper fix a lot more work is required.

It seems that the problem is with locating destructors in destructor calls. I get the impression that currently a destructor node pointing to the declaration is added and the type that is actually destroyed is inferred from the expression every time it is needed. I think destructors should be able to point to specific temporary subexpressions that they destroy in order to deal with multiple temporaries from the same expression.

This fix only ensures that all scenarios which lead to a placement of such a destructor node are handled so no SIGSEV occurs due to a destructor being added, but not handled at all later on.


================
Comment at: lib/Analysis/CFG.cpp:3912-3914
@@ +3911,5 @@
+        if (const Expr *Init = var->getInit()) {
+          if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(Init))
+            Init = EWC->getSubExpr();
+          if (isa<MaterializeTemporaryExpr>(Init))
+            ty = getReferenceInitTemporaryType(astContext, Init);
----------------
NoQ wrote:
> Is this sequence of checks certainly needed? All tests seem to pass without it. Or maybe it's also needed in `addAutomaticObjectDtors()`? Perhaps just nest these checks inside `getReferenceInitTemporaryType()`?
It seems like getReferenceInitTemporaryType includes these two statements, we can remove them from here.


https://reviews.llvm.org/D22419





More information about the cfe-commits mailing list