Use _thread_db_sizeof_pthread to obtain struct pthread size
Resolves: #2034494
This commit is contained in:
parent
4dd83420da
commit
d421f7317a
7
gcc.spec
7
gcc.spec
@ -116,7 +116,7 @@
|
||||
Summary: Various compilers (C, C++, Objective-C, ...)
|
||||
Name: gcc
|
||||
Version: %{gcc_version}
|
||||
Release: %{gcc_release}.2%{?dist}
|
||||
Release: %{gcc_release}.3%{?dist}
|
||||
# libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
|
||||
# GCC Runtime Exception.
|
||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
||||
@ -271,6 +271,7 @@ Patch18: gcc11-Wbidi-chars.patch
|
||||
Patch19: gcc11-dg-ice-fixes.patch
|
||||
Patch20: gcc11-relocatable-pch.patch
|
||||
Patch21: gcc11-dejagnu-multiline.patch
|
||||
Patch22: gcc11-libsanitizer-pthread.patch
|
||||
|
||||
Patch100: gcc11-fortran-fdec-duplicates.patch
|
||||
Patch101: gcc11-fortran-flogical-as-integer.patch
|
||||
@ -820,6 +821,7 @@ so that there cannot be any synchronization problems.
|
||||
%patch19 -p1 -b .ice~
|
||||
%patch20 -p1 -b .pch~
|
||||
%patch21 -p1 -b .dejagnu-multiline~
|
||||
%patch22 -p1 -b .libsanitizer-pthread~
|
||||
|
||||
%if 0%{?rhel} >= 9
|
||||
%patch100 -p1 -b .fortran-fdec-duplicates~
|
||||
@ -3265,6 +3267,9 @@ end
|
||||
%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0.0.0
|
||||
|
||||
%changelog
|
||||
* Tue Feb 8 2022 Marek Polacek <polacek@redhat.com> 11.2.1-9.3
|
||||
- use _thread_db_sizeof_pthread to obtain struct pthread size (#2034494)
|
||||
|
||||
* Mon Feb 7 2022 Marek Polacek <polacek@redhat.com> 11.2.1-9.2
|
||||
- add support for relocation of the PCH data (pch/71934, #2044917)
|
||||
- remove 30_threads/future/members/poll.cc (#2050090)
|
||||
|
54
gcc11-libsanitizer-pthread.patch
Normal file
54
gcc11-libsanitizer-pthread.patch
Normal file
@ -0,0 +1,54 @@
|
||||
Backported from LLVM upstream:
|
||||
|
||||
commit ef14b78d9a144ba81ba02083fe21eb286a88732b
|
||||
Author: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Tue Feb 8 12:46:41 2022 -0800
|
||||
|
||||
[sanitizer] Use _thread_db_sizeof_pthread to obtain struct pthread size
|
||||
|
||||
This symbol has been exported (as an internal GLIBC_PRIVATE symbol) from libc.so.6 starting with glibc 2.34. glibc uses it internally for its libthread_db implementation to enable thread debugging on GDB, so it is unlikely to go away for now.
|
||||
|
||||
Fixes #52989.
|
||||
|
||||
Reviewed By: #sanitizers, MaskRay, vitalybuka
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D119007
|
||||
|
||||
--- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp
|
||||
+++ b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp
|
||||
@@ -265,10 +265,8 @@ void InitTlsSize() { }
|
||||
// sizeof(struct pthread) from glibc.
|
||||
static atomic_uintptr_t thread_descriptor_size;
|
||||
|
||||
-uptr ThreadDescriptorSize() {
|
||||
- uptr val = atomic_load_relaxed(&thread_descriptor_size);
|
||||
- if (val)
|
||||
- return val;
|
||||
+static uptr ThreadDescriptorSizeFallback() {
|
||||
+ uptr val = 0;
|
||||
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
|
||||
int major;
|
||||
int minor;
|
||||
@@ -323,8 +321,21 @@ uptr ThreadDescriptorSize() {
|
||||
#elif defined(__s390__)
|
||||
val = FIRST_32_SECOND_64(1152, 1776); // valid for glibc 2.22
|
||||
#endif
|
||||
+ return val;
|
||||
+}
|
||||
+
|
||||
+uptr ThreadDescriptorSize() {
|
||||
+ uptr val = atomic_load_relaxed(&thread_descriptor_size);
|
||||
if (val)
|
||||
- atomic_store_relaxed(&thread_descriptor_size, val);
|
||||
+ return val;
|
||||
+ // _thread_db_sizeof_pthread is a GLIBC_PRIVATE symbol that is exported in
|
||||
+ // glibc 2.34 and later.
|
||||
+ if (unsigned *psizeof = static_cast<unsigned *>(
|
||||
+ dlsym(RTLD_DEFAULT, "_thread_db_sizeof_pthread")))
|
||||
+ val = *psizeof;
|
||||
+ if (!val)
|
||||
+ val = ThreadDescriptorSizeFallback();
|
||||
+ atomic_store_relaxed(&thread_descriptor_size, val);
|
||||
return val;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user