LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 51171 - SIGSEGV at DeduceTemplateArgumentsByTypeMatch
Summary: SIGSEGV at DeduceTemplateArgumentsByTypeMatch
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC All
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-22 12:08 PDT by Ivan Murashko
Modified: 2021-07-30 05:33 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
The crash reproducer (575 bytes, text/plain)
2021-07-22 12:08 PDT, Ivan Murashko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Murashko 2021-07-22 12:08:34 PDT
Created attachment 25049 [details]
The crash reproducer

There is a SIGSEGV (NULL dereference) at DeduceTemplateArgumentsByTypeMatch as soon as FunctionType parameter passed into the function is NULL. See reproducer at the attachment

The possible fix for the problem is

--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
     HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
     unsigned TDF =
         TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
     // Deduce template arguments from the function type.
Comment 1 Ivan Murashko 2021-07-22 12:33:28 PDT
The proposed fix: https://reviews.llvm.org/D106583
Comment 2 Ivan Murashko 2021-07-30 05:33:45 PDT
Resolved by https://reviews.llvm.org/D106583