[llvm] r244707 - [libFuzzer] use raw C IO to reduce the risk of a deadlock in a signal handler.
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 17:55:10 PDT 2015
Author: kcc
Date: Tue Aug 11 19:55:09 2015
New Revision: 244707
URL: http://llvm.org/viewvc/llvm-project?rev=244707&view=rev
Log:
[libFuzzer] use raw C IO to reduce the risk of a deadlock in a signal handler.
Modified:
llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerIO.cpp?rev=244707&r1=244706&r2=244707&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerIO.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerIO.cpp Tue Aug 11 19:55:09 2015
@@ -66,8 +66,11 @@ void CopyFileToErr(const std::string &Pa
}
void WriteToFile(const Unit &U, const std::string &Path) {
- std::ofstream OF(Path);
- OF.write((const char*)U.data(), U.size());
+ // Use raw C interface because this function may be called from a sig handler.
+ FILE *Out = fopen(Path.c_str(), "w");
+ if (!Out) return;
+ fwrite(U.data(), sizeof(U[0]), U.size(), Out);
+ fclose(Out);
}
void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V,
More information about the llvm-commits
mailing list