[compiler-rt] [compiler-rt][rtsan] adding setlinebuf/setbuffer interception. (PR #122018)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 02:19:44 PST 2025


================
@@ -429,6 +429,28 @@ TEST_F(RtsanFileTest, SetvbufDieWhenRealtime) {
   ExpectRealtimeDeath(Func, "setvbuf");
   ExpectNonRealtimeSurvival(Func);
 }
+
+TEST_F(RtsanFileTest, SetlinebufDieWhenRealtime) {
+  FILE *f = fopen(GetTemporaryFilePath(), "w");
+  EXPECT_THAT(f, Ne(nullptr));
+
+  auto Func = [&f]() { setlinebuf(f); };
+
+  ExpectRealtimeDeath(Func, "setlinebuf");
+  ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanFileTest, SetbufferDieWhenRealtime) {
+  char buffer[1024];
+  size_t size = sizeof(buffer);
+  FILE *f = fopen(GetTemporaryFilePath(), "w");
+  EXPECT_THAT(f, Ne(nullptr));
+
+  auto Func = [&f, &buffer, &size]() { setbuffer(f, buffer, size); };
----------------
fmayer wrote:

nit: we don't need to capture any of those by ref, i think? two ptr and a size_t

https://github.com/llvm/llvm-project/pull/122018


More information about the llvm-commits mailing list