[PATCH] D20943: [LibFuzzer] [WIP] Declare and use sanitizer functions in `fuzzer::ExternalFunctions`
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 6 21:51:13 PDT 2016
kcc added inline comments.
================
Comment at: lib/Fuzzer/FuzzerDriver.cpp:428
@@ +427,3 @@
+// Storage for global ExternalFunctions object.
+ExternalFunctions EF;
+
----------------
delcypher wrote:
> kcc wrote:
> > delcypher wrote:
> > > kcc wrote:
> > > > make this ExternalFunctions *EF
> > > We could also use `std::unique_ptr<ExternalFunctions>` instead or are you fine with an explicit delete?
> > I am *not* ok with std::unique_ptr<ExternalFunctions>
> > And there is no need for an explicit delete.
> > Just
> > EF = new .... ;
> > in main is enough
> >
> > In tests you may have new/delete or even
> > std::unique_ptr<ExternalFunctions> t;
> > EF = t.get()
> > I am *not* ok with std::unique_ptr<ExternalFunctions>
> > And there is no need for an explicit delete.
> > Just
> >
> > EF = new .... ;
> > in main is enough
>
> I don't understand. Why do you want a deliberate leak?
>
> > In tests you may have new/delete or even
> >
> > std::unique_ptr<ExternalFunctions> t;
> > EF = t.get()
>
> Again I don't understand. Why would I want to assign nullptr (that is what `t.get()` would return here) to `EF`?
>
>
This won't be a leak. It will be a global variable which is alive throughout the process.
I meant, in test you could either do
FE = new ...
....
delete EF;
EF = nullptr; // just in case
or, better
std::unique_ptr<ExternalFunctions> t(new ...);
EF = t.get()
...
EF = nullptr; // just tin case
http://reviews.llvm.org/D20943
More information about the llvm-commits
mailing list