Date: Sat, 15 Aug 2020 22:58:07 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r364263 - projects/clang1100-import/contrib/llvm-project/libunwind/src Message-ID: <202008152258.07FMw7ob050961@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Aug 15 22:58:07 2020 New Revision: 364263 URL: https://svnweb.freebsd.org/changeset/base/364263 Log: Temporarily disable libunwind's FrameHeaderCache, until there is a resolution for <https://bugs.llvm.org/show_bug.cgi?id=47181>. The cache implementation depends on dl_iterate_phdr(3) ensuring that its callbacks are not called simultaneously for multiple threads, but that is only the case for the dl_iterate_phdr() implementation in rtld. In a statically linked executable, libc's dl_iterate_phdr() is used, which does no such locking. If multiple threads then call into the unwinder at the same time, it is possible to trigger a segfault. In particular, the statically linked lld which is built during the cross-tools stage can segfault in this way, because it starts multiple worker threads that can exit in parallel. Since our pthread_exit(3) invokes the unwinder, it will therefore call into it in parallel too. Modified: projects/clang1100-import/contrib/llvm-project/libunwind/src/AddressSpace.hpp Modified: projects/clang1100-import/contrib/llvm-project/libunwind/src/AddressSpace.hpp ============================================================================== --- projects/clang1100-import/contrib/llvm-project/libunwind/src/AddressSpace.hpp Sat Aug 15 21:40:36 2020 (r364262) +++ projects/clang1100-import/contrib/llvm-project/libunwind/src/AddressSpace.hpp Sat Aug 15 22:58:07 2020 (r364263) @@ -452,10 +452,12 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) #include "FrameHeaderCache.hpp" // There should be just one of these per process. static FrameHeaderCache ProcessFrameHeaderCache; +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, dl_iterate_cb_data *cbdata) { @@ -476,8 +478,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinf auto cbdata = static_cast<dl_iterate_cb_data *>(data); if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr) return 0; +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data)) return 1; +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE Elf_Addr image_base = calculateImageBase(pinfo); bool found_obj = false; @@ -505,7 +509,9 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinf found_obj = checkAddrInSegment(phdr, image_base, cbdata); } if (found_obj && found_hdr) { +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) ProcessFrameHeaderCache.add(cbdata->sects); +#endif // _LIBUNWIND_USE_FRAME_HEADER_CACHE return 1; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008152258.07FMw7ob050961>