[cfe-dev] static Matcher generate Use After Free
Maxim Ostapenko via cfe-dev
cfe-dev at lists.llvm.org
Tue Jun 6 02:45:35 PDT 2017
On 06/06/17 12:41, Artem Dergachev via cfe-dev wrote:
> I think i've also noticed that static matcher objects don't work, but
> didn't pay enough attention to figure out why.
>
> In clang-tidy, as far as i understand, they don't use static matchers,
> but instead they have long-lived MatchFinder objects filled with all
> the matchers they need, so they don't need to construct the same
> matchers again and again. Maybe that'd be a viable approach in your case?
Hm, but tools/extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
actually has a static matcher:
/// \brief Matcher that finds expressions that are candidates to be
wrapped with
/// 'std::move'.
///
/// Binds the id \c AutoPtrOwnershipTransferId to the expression.
static StatementMatcher MovableArgumentMatcher =
expr(allOf(isLValue(), hasType(AutoPtrType)))
.bind(AutoPtrOwnershipTransferId);
Or perhaps I'm missing something?
-Maxim
>
> 06/06/2017 12:15 PM, Aleksandr wrote:
>> Hello,
>>
>> I need help. I see, that using static Matcher generate error on
>> deallocated itself. For example, if we use:
>> static StatementMatcher MatcherA = callExpr();
>> MatcherA on dealloc tyrying to release reference counter of itself,
>> but reference counter was deleted by method llvm_shutdown, so it use
>> free memory.
>> Is it ok? We shouldn't use static matchers, or we have bug in
>> implementation in reference counter. What is it case?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list