From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id F03D53857810 for ; Tue, 20 Oct 2020 08:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F03D53857810 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: YwUleHOBumwBKAwUeh+QSl9lMGwYpJmK6CUYyVczAI+Qq2GSrRbY00a34gMtjYBscFT80FO1HS ZyHDDucsaAjVzn24iyQsHsFwWBinDFEP3w+9recj1PIl3F9h0Hj8JcBiIpCybcDb3DI1vaLSSb 1k0Oy90aX9aIb8vC6cw19C94cZrCmLrdmjcc3uiFChIGyVfzPG6EYi2g34IWhBoOAO+I2lo/5V xMZ3m/zcFAAasKol2KNrbk/013QDrib3QGR4z3lhX0x9xBvcjpfXMnQINF5sXuIQxUYccITil/ Ueg= X-IronPort-AV: E=Sophos;i="5.77,396,1596528000"; d="diff'?scan'208";a="54186224" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 20 Oct 2020 00:09:23 -0800 IronPort-SDR: gWCQwqozp1APOSIwxiRB1p7q2lhRf8urDakz1+TbRKtEgb4bzQrTbgtkcl6pAiA+RI64RB9fu4 z+A9mZe/DyA8b5cyk4Vm6tCSZvLSLidg3DMshBNaS1DzuWhxacSpht6eiEZcOJAhQLnsFfCa5C qVWZ3y5++JrBuzwPUJPjrTq2+yyzMFxzRNJREMbGMbt3ZWdl4Y3jN1s2dRejYw/Dro5W+ifCKX 9KoKA3kTjJBDjgiOm5PBFv5Q6/V0fOUVuXl6wSAKfRnPa14rcS473V+g+IcpaAdw2I8xWvON6F bAM= Subject: Re: [PATCH] Libsanitizer: merge from master. From: Tobias Burnus To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , References: <3c1342f6-d11c-d510-025c-c208e48c465e@suse.cz> <9195f09f-69a2-9038-3667-db06c8c4327f@suse.cz> <79bd1d9d-c276-caa5-bfeb-85832c2d21fc@codesourcery.com> <0e54079b-15d4-def8-59bd-5fced57ab2b6@codesourcery.com> Message-ID: <0b679651-5886-6c7f-8991-89d061447125@codesourcery.com> Date: Tue, 20 Oct 2020 10:09:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <0e54079b-15d4-def8-59bd-5fced57ab2b6@codesourcery.com> Content-Type: multipart/mixed; boundary="------------8E77AB8C5F0F01F63DD3E293" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 08:09:27 -0000 --------------8E77AB8C5F0F01F63DD3E293 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: quoted-printable On 10/19/20 9:39 AM, Tobias Burnus wrote: > Filled as https://bugs.llvm.org/show_bug.cgi?id=3D47896 That issue was fixed. What's the proper way to apply this patch? Simply committing the attached patch* or is there more required? Tobias *Namely, from LLVM: git diff 51ff04567b2f8d06b2062bd3ed72eab2e93e4466.. compiler-rt/lib/sanitizer_common/; I ignored the changes in compiler-rt/lib/{gwp_asan,memprof}. ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=DFe 201, 80634 M=FCnchen / G= ermany Registergericht M=FCnchen HRB 106955, Gesch=E4ftsf=FChrer: Thomas Heurung, = Alexander Walter --------------8E77AB8C5F0F01F63DD3E293 Content-Type: text/x-patch; charset="UTF-8"; name="fix-san.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix-san.diff" libsanitizer: merge from master libsanitizer/MERGE | 2 +- libsanitizer/sanitizer_common/sanitizer_allocator_report.cpp | 8 ++++++++ libsanitizer/sanitizer_common/sanitizer_allocator_report.h | 1 + libsanitizer/sanitizer_common/sanitizer_flags.inc | 5 +++-- libsanitizer/sanitizer_common/sanitizer_internal_defs.h | 3 +++ libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp | 7 ++----- .../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp | 4 ++++ libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp | 7 ++++++- 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/libsanitizer/MERGE b/libsanitizer/MERGE index d2a25927007..f9657fc6728 100644 --- a/libsanitizer/MERGE +++ b/libsanitizer/MERGE @@ -1,4 +1,4 @@ -51ff04567b2f8d06b2062bd3ed72eab2e93e4466 +f97ca48b1cbbf5da065e94271cb3af4f1c907dd4 The first line of this file holds the git revision number of the last merge done from the master library sources. diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator_report.cpp b/libsanitizer/sanitizer_common/sanitizer_allocator_report.cpp index d74e08010d5..1c6520819ef 100644 --- a/libsanitizer/sanitizer_common/sanitizer_allocator_report.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_allocator_report.cpp @@ -134,4 +134,12 @@ void NORETURN ReportOutOfMemory(uptr requested_size, const StackTrace *stack) { Die(); } +void NORETURN ReportRssLimitExceeded(const StackTrace *stack) { + { + ScopedAllocatorErrorReport report("rss-limit-exceeded", stack); + Report("ERROR: %s: allocator exceeded the RSS limit\n", SanitizerToolName); + } + Die(); +} + } // namespace __sanitizer diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator_report.h b/libsanitizer/sanitizer_common/sanitizer_allocator_report.h index 0653c365c1c..6e4e6b13549 100644 --- a/libsanitizer/sanitizer_common/sanitizer_allocator_report.h +++ b/libsanitizer/sanitizer_common/sanitizer_allocator_report.h @@ -33,6 +33,7 @@ void NORETURN ReportInvalidPosixMemalignAlignment(uptr alignment, void NORETURN ReportAllocationSizeTooBig(uptr user_size, uptr max_size, const StackTrace *stack); void NORETURN ReportOutOfMemory(uptr requested_size, const StackTrace *stack); +void NORETURN ReportRssLimitExceeded(const StackTrace *stack); } // namespace __sanitizer diff --git a/libsanitizer/sanitizer_common/sanitizer_flags.inc b/libsanitizer/sanitizer_common/sanitizer_flags.inc index d1412478fd2..d8e809b0609 100644 --- a/libsanitizer/sanitizer_common/sanitizer_flags.inc +++ b/libsanitizer/sanitizer_common/sanitizer_flags.inc @@ -82,8 +82,9 @@ COMMON_FLAG(bool, print_summary, true, "If false, disable printing error summaries in addition to error " "reports.") COMMON_FLAG(int, print_module_map, 0, - "OS X only (0 - don't print, 1 - print only once before process " - "exits, 2 - print after each report).") + "Print the process module map where supported (0 - don't print, " + "1 - print only once before process exits, 2 - print after each " + "report).") COMMON_FLAG(bool, check_printf, true, "Check printf arguments.") #define COMMON_FLAG_HANDLE_SIGNAL_HELP(signal) \ "Controls custom tool's " #signal " handler (0 - do not registers the " \ diff --git a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h index a6c55148705..8b34e54137d 100644 --- a/libsanitizer/sanitizer_common/sanitizer_internal_defs.h +++ b/libsanitizer/sanitizer_common/sanitizer_internal_defs.h @@ -448,5 +448,8 @@ using namespace __sanitizer; namespace __hwasan { using namespace __sanitizer; } +namespace __memprof { +using namespace __sanitizer; +} #endif // SANITIZER_DEFS_H diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp index af077439478..2bd5564ae05 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -385,12 +385,9 @@ uptr ThreadSelf() { descr_addr = reinterpret_cast(__builtin_thread_pointer()) - ThreadDescriptorSize(); #elif SANITIZER_RISCV64 - uptr tcb_end; - asm volatile("mv %0, tp;\n" : "=r"(tcb_end)); // https://github.com/riscv/riscv-elf-psabi-doc/issues/53 - const uptr kTlsTcbOffset = 0x800; - descr_addr = - reinterpret_cast(tcb_end - kTlsTcbOffset - TlsPreTcbSize()); + uptr thread_pointer = reinterpret_cast(__builtin_thread_pointer()); + descr_addr = thread_pointer - TlsPreTcbSize(); #elif defined(__s390__) descr_addr = reinterpret_cast(__builtin_thread_pointer()); #elif defined(__powerpc64__) diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp index 6a3c00458ef..eb89f1fddc5 100644 --- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp @@ -486,6 +486,10 @@ typedef user_regs_struct regs_struct; #define REG_SP rsp #endif #define ARCH_IOVEC_FOR_GETREGSET +// Support ptrace extensions even when compiled without required kernel support +#ifndef NT_X86_XSTATE +#define NT_X86_XSTATE 0x202 +#endif // Compiler may use FP registers to store pointers. static constexpr uptr kExtraRegs[] = {NT_X86_XSTATE, NT_FPREGSET}; diff --git a/libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp b/libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp index 9ca898a306a..10748f96420 100644 --- a/libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_tls_get_addr.cpp @@ -80,8 +80,13 @@ void DTLS_Destroy() { #if defined(__powerpc64__) || defined(__mips__) // This is glibc's TLS_DTV_OFFSET: // "Dynamic thread vector pointers point 0x8000 past the start of each -// TLS block." +// TLS block." (sysdeps//dl-tls.h) static const uptr kDtvOffset = 0x8000; +#elif defined(__riscv) +// This is glibc's TLS_DTV_OFFSET: +// "Dynamic thread vector pointers point 0x800 past the start of each +// TLS block." (sysdeps/riscv/dl-tls.h) +static const uptr kDtvOffset = 0x800; #else static const uptr kDtvOffset = 0; #endif --------------8E77AB8C5F0F01F63DD3E293--