Hallo again,
There is something I noticed. I made my project a standalone Phasar tool, and I preprocess LLVM IR code by making it feed to llvm::parseIRFile first, then doing some transformations, and then passing it to psr::ProjectIRDB#insert_module. For the next run, I was greeted by a double free error.
The cause is located here: https://github.com/secure-software-engineering/phasar/blob/master/lib/DB/ProjectIRDB.cpp#L706
I originally created the llvm::LLVMContext as a stack variable in my main and used that for parsing. So I suggest to change the signature of that method to something like:
void ProjectIRDB::insertModule(
std::unique_ptr<llvm::Module> M,
std::unique_ptr<llvm::LLVMContext> C
);
So that I can create and move the required context pointer explicitly. For now, I do:
// Phasar cleans this up.
auto context = new llvm::LLVMContext;
That's Ok, but secretly wrapping M->getContext() into a unique pointer is a sneaky move. 😉
Hallo again,
There is something I noticed. I made my project a standalone Phasar tool, and I preprocess LLVM IR code by making it feed to
llvm::parseIRFilefirst, then doing some transformations, and then passing it topsr::ProjectIRDB#insert_module. For the next run, I was greeted by adouble freeerror.The cause is located here: https://github.com/secure-software-engineering/phasar/blob/master/lib/DB/ProjectIRDB.cpp#L706
I originally created the
llvm::LLVMContextas a stack variable in mymainand used that for parsing. So I suggest to change the signature of that method to something like:So that I can create and move the required context pointer explicitly. For now, I do:
That's Ok, but secretly wrapping
M->getContext()into a unique pointer is a sneaky move. 😉