summaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-04-25 18:36:08 +0200
committerJustus Winter <justus@gnupg.org>2016-04-25 18:36:08 +0200
commita048afc4fc5a5c10c27d387499ebf42d0d594331 (patch)
treec3e6ee357810a990b12f60f20994c7fdab978d0d /debian/patches
parent1c0f9ff3456819e2204c4fa476f1393b6493e518 (diff)
add patch series
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/assert0001-libpager-add-missing-include.patch25
-rw-r--r--debian/patches/assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch187
-rw-r--r--debian/patches/assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch157
-rw-r--r--debian/patches/series3
4 files changed, 372 insertions, 0 deletions
diff --git a/debian/patches/assert0001-libpager-add-missing-include.patch b/debian/patches/assert0001-libpager-add-missing-include.patch
new file mode 100644
index 00000000..6b751002
--- /dev/null
+++ b/debian/patches/assert0001-libpager-add-missing-include.patch
@@ -0,0 +1,25 @@
+From b39bff70773c38a3fdcf5b613dd1a10a9dea8d87 Mon Sep 17 00:00:00 2001
+From: Justus Winter <justus@gnupg.org>
+Date: Mon, 25 Apr 2016 18:34:31 +0200
+Subject: [PATCH hurd 1/3] libpager: add missing include
+
+* libpager/demuxer.c: Include <assert.h>.
+---
+ libpager/demuxer.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libpager/demuxer.c b/libpager/demuxer.c
+index 59dd1c5..3fd0516 100644
+--- a/libpager/demuxer.c
++++ b/libpager/demuxer.c
+@@ -15,6 +15,7 @@
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
++#include <assert.h>
+ #include <error.h>
+ #include <mach/mig_errors.h>
+ #include <pthread.h>
+--
+2.1.4
+
diff --git a/debian/patches/assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch b/debian/patches/assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch
new file mode 100644
index 00000000..88b5ff46
--- /dev/null
+++ b/debian/patches/assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch
@@ -0,0 +1,187 @@
+From ec94cd5a410c384c721ace20e010e50dbcf57142 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 20 Jun 2014 15:50:53 +0200
+Subject: [PATCH hurd 2/3] libshouldbeinlibc: add assert(3) variant that prints
+ backtraces
+
+* libshouldbeinlibc/Makefile: Add new files
+* libshouldbeinlibc/assert-backtrace.{c,h}: New files.
+---
+ libshouldbeinlibc/Makefile | 2 +
+ libshouldbeinlibc/assert-backtrace.c | 79 ++++++++++++++++++++++++++++++++++++
+ libshouldbeinlibc/assert-backtrace.h | 60 +++++++++++++++++++++++++++
+ 3 files changed, 141 insertions(+)
+ create mode 100644 libshouldbeinlibc/assert-backtrace.c
+ create mode 100644 libshouldbeinlibc/assert-backtrace.h
+
+diff --git a/libshouldbeinlibc/Makefile b/libshouldbeinlibc/Makefile
+index 633d60e..04c085b 100644
+--- a/libshouldbeinlibc/Makefile
++++ b/libshouldbeinlibc/Makefile
+@@ -29,10 +29,12 @@ SRCS = termsize.c timefmt.c exec-reauth.c maptime-funcs.c \
+ ugids-auth.c ugids-xinl.c ugids-merge.c ugids-imply.c ugids-posix.c \
+ ugids-verify-auth.c nullauth.c \
+ refcount.c \
++ assert-backtrace.c \
+
+ installhdrs = idvec.h timefmt.h maptime.h \
+ wire.h portinfo.h portxlate.h cacheq.h ugids.h nullauth.h \
+ refcount.h \
++ assert-backtrace.h \
+
+ installhdrsubdir = .
+
+diff --git a/libshouldbeinlibc/assert-backtrace.c b/libshouldbeinlibc/assert-backtrace.c
+new file mode 100644
+index 0000000..fd81e24
+--- /dev/null
++++ b/libshouldbeinlibc/assert-backtrace.c
+@@ -0,0 +1,79 @@
++/* Assert with backtraces
++
++ Copyright (C) 2016 Free Software Foundation, Inc.
++
++ This file is part of the GNU Hurd.
++
++ The GNU Hurd is free software; you can redistribute it and/or
++ modify it under the terms of the GNU General Public License as
++ published by the Free Software Foundation; either version 2, or (at
++ your option) any later version.
++
++ The GNU Hurd is distributed in the hope that it will be useful, but
++ WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
++
++#ifndef NDEBUG
++
++#include <error.h>
++#include <errno.h>
++#include <execinfo.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++
++#include "assert-backtrace.h"
++
++static void __attribute__ ((noreturn))
++__assert_fail_base_backtrace (const char *fmt,
++ const char *assertion,
++ const char *file,
++ unsigned int line,
++ const char *function)
++{
++ const size_t size = 128;
++ const size_t skip = 2;
++ int nptrs;
++ void *buffer[size];
++
++ nptrs = backtrace(buffer, size);
++ if (nptrs == 0)
++ error (1, *__errno_location (), "backtrace");
++
++ fprintf (stderr,
++ fmt, program_invocation_name, file, line, function, assertion);
++ backtrace_symbols_fd (&buffer[skip], nptrs - skip, STDERR_FILENO);
++ fflush (stderr);
++
++ /* Die. */
++ abort ();
++}
++
++void
++__assert_fail_backtrace (const char *assertion, const char *file,
++ unsigned int line, const char *function)
++{
++ __assert_fail_base_backtrace ("%s: %s:%u: %s: Assertion '%s' failed.\n",
++ assertion, file, line, function);
++}
++
++void
++__assert_perror_fail_backtrace (int errnum,
++ const char *file,
++ unsigned int line,
++ const char *function)
++{
++ char errbuf[1024];
++
++ char *e = strerror_r (errnum, errbuf, sizeof errbuf);
++ __assert_fail_base_backtrace ("%s: %s:%u: %s: Unexpected error: %s.\n",
++ e, file, line, function);
++
++}
++
++#endif /* ! defined NDEBUG */
+diff --git a/libshouldbeinlibc/assert-backtrace.h b/libshouldbeinlibc/assert-backtrace.h
+new file mode 100644
+index 0000000..c54b810
+--- /dev/null
++++ b/libshouldbeinlibc/assert-backtrace.h
+@@ -0,0 +1,60 @@
++/* Augment failing assertions with backtraces.
++
++ Copyright (C) 1994-2015 Free Software Foundation, Inc.
++
++ This file is part of the GNU Hurd.
++
++ The GNU Hurd is free software; you can redistribute it and/or
++ modify it under the terms of the GNU General Public License as
++ published by the Free Software Foundation; either version 2, or (at
++ your option) any later version.
++
++ The GNU Hurd is distributed in the hope that it will be useful, but
++ WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
++
++#ifndef __ASSERT_BACKTRACE__
++#define __ASSERT_BACKTRACE__
++
++#ifdef NDEBUG
++
++#define assert_backtrace(expr) ((void) 0)
++#define assert_backtrace_perror(errnum) ((void) 0)
++
++#else /* NDEBUG */
++
++/* This prints an "Assertion failed" message, prints a stack trace,
++ and aborts. */
++void __assert_fail_backtrace (const char *assertion,
++ const char *file,
++ unsigned int line,
++ const char *function)
++ __attribute__ ((noreturn, unused));
++
++/* Likewise, but prints the error text for ERRNUM. */
++void __assert_perror_fail_backtrace (int errnum,
++ const char *file,
++ unsigned int line,
++ const char *function)
++ __attribute__ ((noreturn, unused));
++
++#define assert_backtrace(expr) \
++ ((expr) \
++ ? (void) 0 \
++ : __assert_fail_backtrace (__STRING(expr), \
++ __FILE__, __LINE__, \
++ __PRETTY_FUNCTION__))
++
++#define assert_perror_backtrace(expr) \
++ ((expr == 0) \
++ ? (void) 0 \
++ : __assert_perror_fail_backtrace (expr, \
++ __FILE__, __LINE__, \
++ __PRETTY_FUNCTION__))
++
++#endif /* NDEBUG */
++#endif /* __ASSERT_BACKTRACE__ */
+--
+2.1.4
+
diff --git a/debian/patches/assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch b/debian/patches/assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch
new file mode 100644
index 00000000..d33f026f
--- /dev/null
+++ b/debian/patches/assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch
@@ -0,0 +1,157 @@
+From 63e0dc5c9e25b940043ec828de731b7bd412f734 Mon Sep 17 00:00:00 2001
+From: Justus Winter <justus@gnupg.org>
+Date: Mon, 25 Apr 2016 17:58:52 +0200
+Subject: [PATCH hurd 3/3] libshouldbeinlibc: use the new assert in the
+ refcount primitives
+
+* libshouldbeinlibc/refcount.h: Use 'assert_backtrace'.
+---
+ libshouldbeinlibc/refcount.h | 41 +++++++++++++++++++++++++----------------
+ 1 file changed, 25 insertions(+), 16 deletions(-)
+
+diff --git a/libshouldbeinlibc/refcount.h b/libshouldbeinlibc/refcount.h
+index e8b0f5b..0d1fa28 100644
+--- a/libshouldbeinlibc/refcount.h
++++ b/libshouldbeinlibc/refcount.h
+@@ -28,7 +28,7 @@
+ #define REFCOUNT_EI __extern_inline
+ #endif
+
+-#include <assert.h>
++#include <assert-backtrace.h>
+ #include <limits.h>
+ #include <stdint.h>
+
+@@ -41,7 +41,7 @@ typedef unsigned int refcount_t;
+ REFCOUNT_EI void
+ refcount_init (refcount_t *ref, unsigned int references)
+ {
+- assert (references > 0 || !"references must not be zero!");
++ assert_backtrace (references > 0 || !"references must not be zero!");
+ *ref = references;
+ }
+
+@@ -57,7 +57,7 @@ refcount_unsafe_ref (refcount_t *ref)
+ {
+ unsigned int r;
+ r = __atomic_add_fetch (ref, 1, __ATOMIC_RELAXED);
+- assert (r != UINT_MAX || !"refcount overflowed!");
++ assert_backtrace (r != UINT_MAX || !"refcount overflowed!");
+ return r;
+ }
+
+@@ -69,7 +69,7 @@ refcount_ref (refcount_t *ref)
+ {
+ unsigned int r;
+ r = refcount_unsafe_ref (ref);
+- assert (r != 1 || !"refcount detected use-after-free!");
++ assert_backtrace (r != 1 || !"refcount detected use-after-free!");
+ return r;
+ }
+
+@@ -81,7 +81,7 @@ refcount_deref (refcount_t *ref)
+ {
+ unsigned int r;
+ r = __atomic_sub_fetch (ref, 1, __ATOMIC_RELAXED);
+- assert (r != UINT_MAX || !"refcount underflowed!");
++ assert_backtrace (r != UINT_MAX || !"refcount underflowed!");
+ return r;
+ }
+
+@@ -129,7 +129,8 @@ union _references {
+ REFCOUNT_EI void
+ refcounts_init (refcounts_t *ref, uint32_t hard, uint32_t weak)
+ {
+- assert ((hard != 0 || weak != 0) || !"references must not both be zero!");
++ assert_backtrace ((hard != 0 || weak != 0)
++ || !"references must not both be zero!");
+ ref->references = (struct references) { .hard = hard, .weak = weak };
+ }
+
+@@ -147,7 +148,8 @@ refcounts_unsafe_ref (refcounts_t *ref, struct references *result)
+ const union _references op = { .references = { .hard = 1 } };
+ union _references r;
+ r.value = __atomic_add_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.hard != UINT32_MAX || !"refcount overflowed!");
++ assert_backtrace (r.references.hard != UINT32_MAX
++ || !"refcount overflowed!");
+ if (result)
+ *result = r.references;
+ }
+@@ -161,7 +163,7 @@ refcounts_ref (refcounts_t *ref, struct references *result)
+ {
+ struct references r;
+ refcounts_unsafe_ref (ref, &r);
+- assert (! (r.hard == 1 && r.weak == 0)
++ assert_backtrace (! (r.hard == 1 && r.weak == 0)
+ || !"refcount detected use-after-free!");
+ if (result)
+ *result = r;
+@@ -177,7 +179,8 @@ refcounts_deref (refcounts_t *ref, struct references *result)
+ const union _references op = { .references = { .hard = 1 } };
+ union _references r;
+ r.value = __atomic_sub_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.hard != UINT32_MAX || !"refcount underflowed!");
++ assert_backtrace (r.references.hard != UINT32_MAX
++ || !"refcount underflowed!");
+ if (result)
+ *result = r.references;
+ }
+@@ -207,8 +210,10 @@ refcounts_promote (refcounts_t *ref, struct references *result)
+ { .references = { .weak = ~0U, .hard = 1} };
+ union _references r;
+ r.value = __atomic_add_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.hard != UINT32_MAX || !"refcount overflowed!");
+- assert (r.references.weak != UINT32_MAX || !"refcount underflowed!");
++ assert_backtrace (r.references.hard != UINT32_MAX
++ || !"refcount overflowed!");
++ assert_backtrace (r.references.weak != UINT32_MAX
++ || !"refcount underflowed!");
+ if (result)
+ *result = r.references;
+ }
+@@ -235,8 +240,10 @@ refcounts_demote (refcounts_t *ref, struct references *result)
+ const union _references op = { .references = { .hard = ~0U } };
+ union _references r;
+ r.value = __atomic_add_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.hard != UINT32_MAX || !"refcount underflowed!");
+- assert (r.references.weak != UINT32_MAX || !"refcount overflowed!");
++ assert_backtrace (r.references.hard != UINT32_MAX
++ || !"refcount underflowed!");
++ assert_backtrace (r.references.weak != UINT32_MAX
++ || !"refcount overflowed!");
+ if (result)
+ *result = r.references;
+ }
+@@ -255,7 +262,8 @@ refcounts_unsafe_ref_weak (refcounts_t *ref, struct references *result)
+ const union _references op = { .references = { .weak = 1 } };
+ union _references r;
+ r.value = __atomic_add_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.weak != UINT32_MAX || !"refcount overflowed!");
++ assert_backtrace (r.references.weak != UINT32_MAX
++ || !"refcount overflowed!");
+ if (result)
+ *result = r.references;
+ }
+@@ -269,7 +277,7 @@ refcounts_ref_weak (refcounts_t *ref, struct references *result)
+ {
+ struct references r;
+ refcounts_unsafe_ref_weak (ref, &r);
+- assert (! (r.hard == 0 && r.weak == 1)
++ assert_backtrace (! (r.hard == 0 && r.weak == 1)
+ || !"refcount detected use-after-free!");
+ if (result)
+ *result = r;
+@@ -285,7 +293,8 @@ refcounts_deref_weak (refcounts_t *ref, struct references *result)
+ const union _references op = { .references = { .weak = 1 } };
+ union _references r;
+ r.value = __atomic_sub_fetch (&ref->value, op.value, __ATOMIC_RELAXED);
+- assert (r.references.weak != UINT32_MAX || !"refcount underflowed!");
++ assert_backtrace (r.references.weak != UINT32_MAX
++ || !"refcount underflowed!");
+ if (result)
+ *result = r.references;
+ }
+--
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 0fa931f2..bdf79133 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -48,3 +48,6 @@ fixes0002-libtrivfs-fix-notion-of-privileged-user.patch
fixes0003-utils-settrans-implement-active-translator-stacking.patch
fixes0004-Avoid-superfluous-locking-of-node.patch
fixes0005-fstests-new-micro-benchmark.patch
+assert0001-libpager-add-missing-include.patch
+assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch
+assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch