<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 25, 2015 at 1:19 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Thu, Jun 25, 2015 at 12:53 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br><div><blockquote type="cite"><div>On Jun 25, 2015, at 11:54, Justin Bogner <<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>> wrote:</div><br><div><div>Jordan Rose <<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>> writes:<br><blockquote type="cite">Author: jrose<br>Date: Wed Jun 24 14:27:02 2015<br>New Revision: 240571<br><br>URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D240571-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=JNywv-8fNgA5ogEOY83nKeNJRpAQIkJvoRM1D9tAMy0&s=zOvrqYIK9Pt0ELEqHO27uNICTI5Vbz-eqFTFtP9S_88&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=240571&view=rev</a><br>Log:<br>[Preprocessor] Iterating over all macros should include those from modules.<br><br>So, iterate over the list of macros mentioned in modules, and make sure those<br>are in the master table.<br></blockquote><br>This introduces a null dereference in Preprocessor::findDirectiveAtLoc.<br>It triggers in clang/test/Modules/crashes.m, so you can find it by<br>adding an assert next to the very relevant sounding FIXME like so:<br><br>--- a/include/clang/Lex/Preprocessor.h<br>+++ b/include/clang/Lex/Preprocessor.h<br>@@ -454,6 +454,7 @@ class Preprocessor : public RefCountedBase<Preprocessor> {<br>     MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,<br>                                                SourceManager &SourceMgr) const {<br>       // FIXME: Incorporate module macros into the result of this.<br>+      assert(getLatest() != nullptr);<br>       return getLatest()->findDirectiveAtLoc(Loc, SourceMgr);<br>     }<br><br>I found this with ubsan, but I still need a couple of clang patches<br>reviewed before I can make a bot to catch such things. For anyone<br>interested:<br><br>  <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131431.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131431.html</a><br>  <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131432.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131432.html</a><br>  <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131433.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131433.html</a><br></div></div></blockquote></div><br></div></div><div>Hm, thanks. I'm not sure whether this means we/I should be more circumspect about what gets added to the Macros table, or whether findDirectiveAtLoc should not assume that everything in the Macros table is currently valid.</div></div></blockquote><div><br></div></div></div><div>I think this is a bug in findDirectiveAtLoc(): it's assuming that every MacroState has at least one local MacroDirective, which is not necessarily the case. I think we can just return a default-constructed DefInfo here if there is no latest macro directive, at least for now. (Longer-term, it'd be nice if providing a location within a module would get the latest macro directive visible at that location within that module, but it doesn't seem like a particularly high priority.)</div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Should be  fixed in r240691.</div></div>