From 47b41817be1552119bdff877af5885429be4afad Mon Sep 17 00:00:00 2001 From: "jiawei.wang" Date: Fri, 17 Nov 2023 23:49:39 +1100 Subject: [PATCH 1/2] fix if offsetVarAndGepTypePair.second is nullptr since it is from ExternalAPI --- svf/lib/MemoryModel/AccessPath.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index 99a96a897..ea7e7234f 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -112,6 +112,9 @@ APOffset AccessPath::computeConstantByteOffset() const /// i = 0, type: [10 x i8]*, PtrType, op = 0 /// i = 1, type: [10 x i8], ArrType, op = 8 const SVFType* type = offsetVarAndGepTypePairs[i].second; + /// if offsetVarAndGepTypePairs[i].second is nullptr, it means + /// this GepStmt comes from external API, assert + assert(type && "this GepStmt comes from ExternalAPI cannot call this api"); const SVFType* type2 = type; if (const SVFArrayType* arrType = SVFUtil::dyn_cast(type)) { From 3788a5f86b6f40ce964233f236a95465be506922 Mon Sep 17 00:00:00 2001 From: "jiawei.wang" Date: Sat, 18 Nov 2023 00:11:03 +1100 Subject: [PATCH 2/2] add comment on this assert to indicate where this GepStmt is assigned --- svf/lib/MemoryModel/AccessPath.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index ea7e7234f..bea2a6ed0 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -113,7 +113,8 @@ APOffset AccessPath::computeConstantByteOffset() const /// i = 1, type: [10 x i8], ArrType, op = 8 const SVFType* type = offsetVarAndGepTypePairs[i].second; /// if offsetVarAndGepTypePairs[i].second is nullptr, it means - /// this GepStmt comes from external API, assert + /// GepStmt comes from external API, this GepStmt is assigned in SVFIRExtAPI.cpp + /// at SVFIRBuilder::getBaseTypeAndFlattenedFields ls.addOffsetVarAndGepTypePair() assert(type && "this GepStmt comes from ExternalAPI cannot call this api"); const SVFType* type2 = type; if (const SVFArrayType* arrType = SVFUtil::dyn_cast(type))