-
Notifications
You must be signed in to change notification settings - Fork 156
Description
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. 😉