[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[glibc] 01/01: debian/patches/ia64/git-ia64-crash-thread-exit.diff: Fix crash on thread exit on IA64. Closes: #883285.



This is an automated email from the git hooks/post-receive script.

aurel32 pushed a commit to branch sid
in repository glibc.

commit 379f2e613236f1c68314c984fd2b5589155a1755
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Fri Dec 1 22:34:29 2017 +0100

    debian/patches/ia64/git-ia64-crash-thread-exit.diff: Fix crash on thread exit on IA64.  Closes: #883285.
---
 debian/changelog                                   |  2 +
 .../patches/ia64/git-ia64-crash-thread-exit.diff   | 79 ++++++++++++++++++++++
 debian/patches/series                              |  2 +
 3 files changed, 83 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 966ca2a..b5a88c8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,8 @@ glibc (2.25-3) UNRELEASED; urgency=medium
   * debian/patches/submitted-ldconfig-c-collation.diff: New patch to process
     include directives in ldconfig using the C/POSIX collation.  Closes:
     #882255.
+  * debian/patches/ia64/git-ia64-crash-thread-exit.diff: Fix crash on thread
+    exit on IA64.  Closes: #883285.
 
   [ Samuel Thibault ]
   * libc0.3.symbols.hurd-i386: Update against newer hurd definitions.
diff --git a/debian/patches/ia64/git-ia64-crash-thread-exit.diff b/debian/patches/ia64/git-ia64-crash-thread-exit.diff
new file mode 100644
index 0000000..1cdc778
--- /dev/null
+++ b/debian/patches/ia64/git-ia64-crash-thread-exit.diff
@@ -0,0 +1,79 @@
+2017-08-29  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+	[BZ #21672]
+	* nptl/allocatestack.c (advise_stack_range): New function.
+	* nptl/pthread_create.c (START_THREAD_DEFN): Move logic to mark
+	stack non required to advise_stack_range at allocatestack.c
+
+--- a/nptl/allocatestack.c
++++ b/nptl/allocatestack.c
+@@ -340,6 +340,33 @@
+ }
+ 
+ 
++/* Mark the memory of the stack as usable to the kernel.  It frees everything
++   except for the space used for the TCB itself.  */
++static inline void
++__always_inline
++advise_stack_range (void *mem, size_t size, uintptr_t pd, size_t guardsize)
++{
++  uintptr_t sp = (uintptr_t) CURRENT_STACK_FRAME;
++  size_t pagesize_m1 = __getpagesize () - 1;
++#if _STACK_GROWS_DOWN && !defined(NEED_SEPARATE_REGISTER_STACK)
++  size_t freesize = (sp - (uintptr_t) mem) & ~pagesize_m1;
++  assert (freesize < size);
++  if (freesize > PTHREAD_STACK_MIN)
++    __madvise (mem, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
++#else
++  /* Page aligned start of memory to free (higher than or equal
++     to current sp plus the minimum stack size).  */
++  uintptr_t freeblock = (sp + PTHREAD_STACK_MIN + pagesize_m1) & ~pagesize_m1;
++  uintptr_t free_end = (pd - guardsize) & ~pagesize_m1;
++  if (free_end > freeblock)
++    {
++      size_t freesize = free_end - freeblock;
++      assert (freesize < size);
++      __madvise ((void*) freeblock, freesize, MADV_DONTNEED);
++    }
++#endif
++}
++
+ /* Returns a usable stack for a new thread either by allocating a
+    new stack or reusing a cached stack of sufficient size.
+    ATTR must be non-NULL and point to a valid pthread_attr.
+--- a/nptl/pthread_create.c
++++ b/nptl/pthread_create.c
+@@ -545,31 +545,8 @@
+     }
+ #endif
+ 
+-  /* Mark the memory of the stack as usable to the kernel.  We free
+-     everything except for the space used for the TCB itself.  */
+-  size_t pagesize_m1 = __getpagesize () - 1;
+-#ifdef _STACK_GROWS_DOWN
+-  char *sp = CURRENT_STACK_FRAME;
+-  size_t freesize = (sp - (char *) pd->stackblock) & ~pagesize_m1;
+-  assert (freesize < pd->stackblock_size);
+-  if (freesize > PTHREAD_STACK_MIN)
+-    __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
+-#else
+-  /* Page aligned start of memory to free (higher than or equal
+-     to current sp plus the minimum stack size).  */
+-  void *freeblock = (void*)((size_t)(CURRENT_STACK_FRAME
+-				     + PTHREAD_STACK_MIN
+-				     + pagesize_m1)
+-				    & ~pagesize_m1);
+-  char *free_end = (char *) (((uintptr_t) pd - pd->guardsize) & ~pagesize_m1);
+-  /* Is there any space to free?  */
+-  if (free_end > (char *)freeblock)
+-    {
+-      size_t freesize = (size_t)(free_end - (char *)freeblock);
+-      assert (freesize < pd->stackblock_size);
+-      __madvise (freeblock, freesize, MADV_DONTNEED);
+-    }
+-#endif
++  advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd,
++		      pd->guardsize);
+ 
+   /* If the thread is detached free the TCB.  */
+   if (IS_DETACHED (pd))
diff --git a/debian/patches/series b/debian/patches/series
index bdbf764..94763cb 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -141,6 +141,8 @@ i386/local-biarch.diff
 i386/local-cmov.diff
 i386/unsubmitted-quiet-ldconfig.diff
 
+ia64/git-ia64-crash-thread-exit.diff
+
 kfreebsd/submitted-waitid.diff
 kfreebsd/submitted-auxv.diff
 kfreebsd/local-config_h_in.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-glibc/glibc.git


Reply to: