From d4d45be073dfb9d595c68b4881d09610955d45af Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Thu, 16 Sep 2021 18:03:53 +0100 Subject: map_handle: On POSIX suppress a benign cause of tsan failure. --- .../llfio/v2.0/detail/impl/posix/map_handle.ipp | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp index 697dd8b6..d83d5d7c 100644 --- a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp @@ -156,10 +156,10 @@ map_handle::~map_handle() auto ret = map_handle::close(); if(ret.has_error()) { - LLFIO_LOG_FATAL(_v.fd, - "FATAL: map_handle::~map_handle() close failed. Cause is typically other code modifying mapped regions. If on Linux, you may have exceeded the " - "64k VMA process limit, set the LLFIO_DEBUG_LINUX_MUNMAP macro at the top of posix/map_handle.ipp to cause dumping of VMAs to " - "/tmp/llfio_unmap_debug_smaps.txt, and combine with strace to figure it out."); + LLFIO_LOG_FATAL( + _v.fd, "FATAL: map_handle::~map_handle() close failed. Cause is typically other code modifying mapped regions. If on Linux, you may have exceeded the " + "64k VMA process limit, set the LLFIO_DEBUG_LINUX_MUNMAP macro at the top of posix/map_handle.ipp to cause dumping of VMAs to " + "/tmp/llfio_unmap_debug_smaps.txt, and combine with strace to figure it out."); abort(); } } @@ -313,17 +313,31 @@ static inline result do_mmap(native_handle_type &nativeh, void *ataddr, prot |= PROT_READ | PROT_WRITE; flags &= ~MAP_SHARED; flags |= MAP_PRIVATE; - nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable; + if((nativeh.behaviour & + (native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable)) != + (native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable)) + { + nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable; + } } else if(_flag & section_handle::flag::write) { prot = (_flag & section_handle::flag::write_via_syscall) ? PROT_READ : (PROT_READ | PROT_WRITE); - nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable; + if((nativeh.behaviour & + (native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable)) != + (native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable)) + { + nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable; + } } else if(_flag & section_handle::flag::read) { prot |= PROT_READ; - nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable; + if((nativeh.behaviour & (native_handle_type::disposition::seekable | native_handle_type::disposition::readable)) != + (native_handle_type::disposition::seekable | native_handle_type::disposition::readable)) + { + nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable; + } } if(_flag & section_handle::flag::execute) { -- cgit v1.2.3