[libcxx-commits] [PATCH] D137129: [libc++][Android] Avoid triggering fdsan in filebuf test
Ryan Prichard via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 31 15:49:14 PDT 2022
rprichard created this revision.
rprichard added reviewers: ldionne, danalbert.
Herald added a subscriber: danielkiss.
Herald added a project: All.
rprichard requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
The fd is opened by std::filebuf, which uses stdio (FILE*). Attempting
to close the fd directly with close() would trigger fdsan.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137129
Files:
libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/close.pass.cpp
Index: libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/close.pass.cpp
===================================================================
--- libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/close.pass.cpp
+++ libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/close.pass.cpp
@@ -42,12 +42,18 @@
// Use the internal method to create filebuf from the file descriptor.
assert(f.__open(fd, std::ios_base::out) != 0);
assert(f.is_open());
+
+ // With Bionic, fdsan aborts the process when close() is called on an fd
+ // belonging to a FILE*, so disable this part of the test. See
+ // https://github.com/android/ndk/issues/1626.
+#if !defined(__BIONIC__)
// Close the file descriptor directly to force filebuf::close to fail.
assert(close(fd) == 0);
// Ensure that filebuf::close handles the failure.
assert(f.close() == nullptr);
assert(!f.is_open());
assert(f.close() == nullptr);
+#endif
}
#endif
std::remove(temp.c_str());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137129.472165.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221031/8b7a0b0c/attachment.bin>
More information about the libcxx-commits
mailing list