[PATCH] Inconsistency in Preprocessor::ReleaseMacroInfo(MacroInfo *MI)
Vassil Vassilev
vvasilev at cern.ch
Sun Aug 3 11:10:50 PDT 2014
Hi Yaron,
Yes I meant double destruction.
Vassil
On 03/08/14 20:08, Yaron Keren wrote:
> Hi Vassil,
>
> Do you mean double destruction (not deletion) of MacroInfo first time
> in ReleaseMacroInfo and the second time in ~Preprocessor via
> ~MacroInfoChain?
>
> while (MacroInfoChain *I = MIChainHead) {
> MIChainHead = I->Next;
> I->~MacroInfoChain();
> }
>
> or something else?
>
> Yaron
>
>
>
> 2014-08-02 23:05 GMT+03:00 Vassil Vassilev <vvasilev at cern.ch
> <mailto:vvasilev at cern.ch>>:
>
> Hi,
> In cases where ReleaseMacroInfo gets called and it doesn't
> cleanup the Preprocessor's MIChainHead can lead to double
> deletion. I am sending the patch that fixes the problem for me.
> Vassil
>
>
> diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
> index 5f38387..1a9b5eb 100644
> --- a/lib/Lex/PPDirectives.cpp
> +++ b/lib/Lex/PPDirectives.cpp
> @@ -94,6 +94,14 @@
> Preprocessor::AllocateVisibilityMacroDirective(SourceLocation Loc,
> /// error in the macro definition.
> void Preprocessor::ReleaseMacroInfo(MacroInfo *MI) {
> // Don't try to reuse the storage; this only happens on error
> paths.
> +
> + // If this is on the macro info chain, avoid double deletion on
> teardown.
> + while (MacroInfoChain *I = MIChainHead) {
> + if (&(I->MI) == MI)
> + I->Next = (I->Next) ? I->Next->Next : 0;
> + MIChainHead = I->Next;
> + }
> +
> MI->~MacroInfo();
> }
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu <mailto:cfe-commits at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140803/d2348b23/attachment.html>
More information about the cfe-commits
mailing list