svf-tools 1.0.658 → 1.0.659

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.658",
3
+ "version": "1.0.659",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -223,6 +223,9 @@ public:
223
223
  // SaberCondAllocator.cpp
224
224
  static const Option<bool> PrintPathCond;
225
225
 
226
+ // SaberSVFGBuilder.cpp
227
+ static const Option<bool> CollectExtRetGlobals;
228
+
226
229
  // SVFUtil.cpp
227
230
  static const Option<bool> DisableWarn;
228
231
 
@@ -31,6 +31,7 @@
31
31
  #include "SABER/SaberCheckerAPI.h"
32
32
  #include "MemoryModel/PointerAnalysisImpl.h"
33
33
  #include "Graphs/SVFG.h"
34
+ #include "Util/Options.h"
34
35
 
35
36
  using namespace SVF;
36
37
  using namespace SVFUtil;
@@ -99,17 +100,48 @@ void SaberSVFGBuilder::collectGlobals(BVDataPTAImpl* pta)
99
100
  }
100
101
  }
101
102
 
102
- PointsTo& SaberSVFGBuilder::CollectPtsChain(BVDataPTAImpl* pta,NodeID id, NodeToPTSSMap& cachedPtsMap)
103
+
104
+ /*
105
+ * https://github.com/SVF-tools/SVF/issues/991
106
+ *
107
+ * Originally, this function will collect all base pointers with all their fields
108
+ * inside the points-to set of global variables. But if a global variable points
109
+ * to the pointer returned by malloc() at some program points, then all pointers
110
+ * returned by malloc() will be included in the global set because of the
111
+ * context-insensitive pointer analysis results. This will make saber abandon
112
+ * too many slicing thus miss potential bugs.
113
+ *
114
+ * We add an option "saber-collect-extret-globals" to control whether this function
115
+ * will collect external functions' returned pointers. This option is true by default,
116
+ * making it to be false will let saber analyze more slicing but cause performance downgrade.
117
+ *
118
+ */
119
+ PointsTo& SaberSVFGBuilder::CollectPtsChain(BVDataPTAImpl* pta, NodeID id, NodeToPTSSMap& cachedPtsMap)
103
120
  {
104
121
  SVFIR* pag = svfg->getPAG();
105
122
 
106
123
  NodeID baseId = pag->getBaseObjVar(id);
107
124
  NodeToPTSSMap::iterator it = cachedPtsMap.find(baseId);
108
125
  if(it!=cachedPtsMap.end())
126
+ {
109
127
  return it->second;
128
+ }
110
129
  else
111
130
  {
112
131
  PointsTo& pts = cachedPtsMap[baseId];
132
+ // base object
133
+ if (!Options::CollectExtRetGlobals())
134
+ {
135
+ if(pta->isFIObjNode(baseId) && pag->getGNode(baseId)->hasValue())
136
+ {
137
+ const SVFCallInst* inst = SVFUtil::dyn_cast<SVFCallInst>(pag->getGNode(baseId)->getValue());
138
+ if(inst && SVFUtil::isExtCall(inst))
139
+ {
140
+ return pts;
141
+ }
142
+ }
143
+ }
144
+
113
145
  pts |= pag->getFieldsAfterCollapse(baseId);
114
146
 
115
147
  WorkList worklist;
@@ -127,7 +159,6 @@ PointsTo& SaberSVFGBuilder::CollectPtsChain(BVDataPTAImpl* pta,NodeID id, NodeTo
127
159
  }
128
160
  return pts;
129
161
  }
130
-
131
162
  }
132
163
 
133
164
  /*!
@@ -679,6 +679,14 @@ const Option<bool> Options::PrintPathCond(
679
679
  );
680
680
 
681
681
 
682
+ // SaberSVFGBuilder.cpp
683
+ const Option<bool> Options::CollectExtRetGlobals(
684
+ "saber-collect-extret-globals",
685
+ "Don't include pointers returned by external function during collecting globals",
686
+ true
687
+ );
688
+
689
+
682
690
  // SVFUtil.cpp
683
691
  const Option<bool> Options::DisableWarn(
684
692
  "dwarn",