[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

Emmett Neyman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 10:57:58 PDT 2018

emmettneyman added inline comments.

Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:173
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
morehouse wrote:
> emmettneyman wrote:
> > morehouse wrote:
> > > Why do we need to copy the function somewhere else?  Looks very error-prone and unnecessary.  Also makes this patch larger than it needs to be.
> > I'm copying the functions because otherwise, the generated machine code gets lost as soon as we exit that function's scope. So I'd have to run the functions inside `CreateJITFunction` if I don't copy it.
> > 
> > I thought about doing it this way: moving the code from `RunFuncsOnInputs` to the bottom of `CreateJITFunction` and then comparing the arrays after both calls to `CreateJITFunction` inside `HandleLLVM`. Do you think that would be cleaner?
> Or just increase the scope of `EE`.
When I tried to increase the scope of `EE` (and also `M` since `EntryFunc` lives inside the module), the program segfaulted immediately after exiting `CreateJITFunc`, I think while trying to deconstruct an object from the function. I'm not sure if there's a way around this since there are so many objects being created inside `CreateJITFunc`. But it's definitely possible I'm missing something with how `unique_ptr` work.

  rC Clang


More information about the cfe-commits mailing list