Bug#841124: elfutils: diff for NMU version 0.166-2.2

2016-10-18 Thread John Paul Adrian Glaubitz
On 10/18/2016 09:36 AM, James Clarke wrote:
> I've prepared an NMU for elfutils (versioned as 0.166-2.2). The diff
> is attached to this message.

Since this is a serious bug in an important package, I uploaded the NMU
right away, but just made the line-breaking in the changelog a bit
saner.

Please apply the attached patch to the elfutils packaging source instead.

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
diff -Nru elfutils-0.166/debian/changelog elfutils-0.166/debian/changelog
--- elfutils-0.166/debian/changelog	2016-10-07 16:16:12.0 +0200
+++ elfutils-0.166/debian/changelog	2016-10-18 09:13:34.0 +0200
@@ -1,3 +1,11 @@
+elfutils (0.166-2.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * testsuite-amd64-fix-backtrace-native.patch: Backport upstream
+patch to fix FTBFS on amd64 (Closes: #841124)
+
+ -- James Clarke   Tue, 18 Oct 2016 08:13:34 +0100
+
 elfutils (0.166-2.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -Nru elfutils-0.166/debian/patches/series elfutils-0.166/debian/patches/series
--- elfutils-0.166/debian/patches/series	2016-07-23 18:46:11.0 +0200
+++ elfutils-0.166/debian/patches/series	2016-10-18 09:13:34.0 +0200
@@ -10,3 +10,4 @@
 0003-Add-mips-n64-relocation-format-hack.patch
 hurd_path.patch
 ignore_strmerge.diff
+testsuite-amd64-fix-backtrace-native.patch
diff -Nru elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch
--- elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch	1970-01-01 01:00:00.0 +0100
+++ elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch	2016-10-18 09:13:34.0 +0200
@@ -0,0 +1,220 @@
+From 9008499a5276c45b37bc0adb47e7ad227e6ba2a9 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard 
+Date: Thu, 25 Aug 2016 17:17:23 +0200
+Subject: [PATCH 1/1] tests: Simplify backtrace-native tests. Drop raise jmp
+ patching for x86_64.
+
+The backtrace-native[-biarch] testcase was a little too clever in places
+making it unreliable.
+
+On x86_64 we tried to make an interesting backtrace by catching the
+first signal and then replacing the pc with the address of the first
+instruction of a function. Then we would raise a new signal, through
+ptrace, to create a backtrace that went from a signal frame into a
+frame at the start of a function. That way we could check that we were
+trying to fetch the correct CFI for the (jmp) function even at the
+first instruction (normally we would substract one from the return
+address to get at the call address).
+
+This works as long as the CFI for the jmp() function is identical to
+the CFI for the raise() function that we "patched away". Unfortunately
+on Fedora rawhide glibc has a rewritten raise() implementation that has
+different CFI, in particular the CFA is calculated differently. Making
+the testcase fail because we cannot properly unwind from jmp().
+So this special x86_64 case has been disabled (the code is still there
+in case we find another way to test this in a more reliable way).
+
+On Ubuntu there have been spurious testcase failures because
+see_exec_module found two Dwfl_Modules with the same path. This would
+trigger an assert. Although this might indicate some issue (maybe we
+are not parsing the proc/pid/map correctly?) it isn't clear that it
+really is a bug. Since the assert is not very helpful finding any
+actual bug and for the testcase it is only necessary that the first
+Dwfl_Module that represents the executable is found we just pick that
+Dwfl_Module and don't iterate through any of the others.
+
+Signed-off-by: Mark Wielaard 
+---
+ tests/backtrace-child.c | 18 ++
+ tests/backtrace.c   | 39 +--
+ 3 files changed, 51 insertions(+), 22 deletions(-)
+
+diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
+index 40e7b32..cf4547c 100644
+--- a/tests/backtrace-child.c
 b/tests/backtrace-child.c
+@@ -1,5 +1,5 @@
+ /* Test child for parent backtrace test.
+-   Copyright (C) 2013 Red Hat, Inc.
++   Copyright (C) 2013, 2016 Red Hat, Inc.
+This file is part of elfutils.
+ 
+This file is free software; you can redistribute it and/or modify
+@@ -19,7 +19,8 @@
+--ptraceme will call ptrace (PTRACE_TRACEME) in the two threads.
+--gencore will call abort () at its end.
+Main thread will signal SIGUSR2.  Other thread will signal SIGUSR1.
+-   On x86_64 only:
++   There used to be a difference between x86_64 and other architectures.
++   To test getting a signal at the very first instruction of a function:
+  PC will get changed to function 'jmp' by backtrace.c function
+  prepare_thread.  Then SIGUSR2 will be signalled to backtrace-child
+  which wil

Bug#841124: elfutils: diff for NMU version 0.166-2.2

2016-10-18 Thread James Clarke
Control: tags 841124 + patch

Dear maintainer,

I've prepared an NMU for elfutils (versioned as 0.166-2.2). The diff
is attached to this message.

Regards,
James
diff -Nru elfutils-0.166/debian/changelog elfutils-0.166/debian/changelog
--- elfutils-0.166/debian/changelog 2016-10-07 15:16:12.0 +0100
+++ elfutils-0.166/debian/changelog 2016-10-18 08:13:34.0 +0100
@@ -1,3 +1,11 @@
+elfutils (0.166-2.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * testsuite-amd64-fix-backtrace-native.patch: Backport upstream patch to fix
+FTBFS on amd64 (Closes: #841124)
+
+ -- James Clarke   Tue, 18 Oct 2016 08:13:34 +0100
+
 elfutils (0.166-2.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -Nru elfutils-0.166/debian/patches/series 
elfutils-0.166/debian/patches/series
--- elfutils-0.166/debian/patches/series2016-07-23 17:46:11.0 
+0100
+++ elfutils-0.166/debian/patches/series2016-10-18 08:12:01.0 
+0100
@@ -10,3 +10,4 @@
 0003-Add-mips-n64-relocation-format-hack.patch
 hurd_path.patch
 ignore_strmerge.diff
+testsuite-amd64-fix-backtrace-native.patch
diff -Nru 
elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch 
elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch
--- elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch
1970-01-01 01:00:00.0 +0100
+++ elfutils-0.166/debian/patches/testsuite-amd64-fix-backtrace-native.patch
2016-10-18 08:12:51.0 +0100
@@ -0,0 +1,220 @@
+From 9008499a5276c45b37bc0adb47e7ad227e6ba2a9 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard 
+Date: Thu, 25 Aug 2016 17:17:23 +0200
+Subject: [PATCH 1/1] tests: Simplify backtrace-native tests. Drop raise jmp
+ patching for x86_64.
+
+The backtrace-native[-biarch] testcase was a little too clever in places
+making it unreliable.
+
+On x86_64 we tried to make an interesting backtrace by catching the
+first signal and then replacing the pc with the address of the first
+instruction of a function. Then we would raise a new signal, through
+ptrace, to create a backtrace that went from a signal frame into a
+frame at the start of a function. That way we could check that we were
+trying to fetch the correct CFI for the (jmp) function even at the
+first instruction (normally we would substract one from the return
+address to get at the call address).
+
+This works as long as the CFI for the jmp() function is identical to
+the CFI for the raise() function that we "patched away". Unfortunately
+on Fedora rawhide glibc has a rewritten raise() implementation that has
+different CFI, in particular the CFA is calculated differently. Making
+the testcase fail because we cannot properly unwind from jmp().
+So this special x86_64 case has been disabled (the code is still there
+in case we find another way to test this in a more reliable way).
+
+On Ubuntu there have been spurious testcase failures because
+see_exec_module found two Dwfl_Modules with the same path. This would
+trigger an assert. Although this might indicate some issue (maybe we
+are not parsing the proc/pid/map correctly?) it isn't clear that it
+really is a bug. Since the assert is not very helpful finding any
+actual bug and for the testcase it is only necessary that the first
+Dwfl_Module that represents the executable is found we just pick that
+Dwfl_Module and don't iterate through any of the others.
+
+Signed-off-by: Mark Wielaard 
+---
+ tests/backtrace-child.c | 18 ++
+ tests/backtrace.c   | 39 +--
+ 3 files changed, 51 insertions(+), 22 deletions(-)
+
+diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
+index 40e7b32..cf4547c 100644
+--- a/tests/backtrace-child.c
 b/tests/backtrace-child.c
+@@ -1,5 +1,5 @@
+ /* Test child for parent backtrace test.
+-   Copyright (C) 2013 Red Hat, Inc.
++   Copyright (C) 2013, 2016 Red Hat, Inc.
+This file is part of elfutils.
+ 
+This file is free software; you can redistribute it and/or modify
+@@ -19,7 +19,8 @@
+--ptraceme will call ptrace (PTRACE_TRACEME) in the two threads.
+--gencore will call abort () at its end.
+Main thread will signal SIGUSR2.  Other thread will signal SIGUSR1.
+-   On x86_64 only:
++   There used to be a difference between x86_64 and other architectures.
++   To test getting a signal at the very first instruction of a function:
+  PC will get changed to function 'jmp' by backtrace.c function
+  prepare_thread.  Then SIGUSR2 will be signalled to backtrace-child
+  which will invoke function sigusr2.
+@@ -66,8 +67,17 @@
+# 5 0xf77c1a48 - 1  start
+# 6 0xf77699da - 1  start_thread
+# 7 0xf769bbfe - 1  __clone
++
++   But the raise jmp patching was unreliable. It depends on the CFI for the 
raise()
++   function in glibc to be the same as for the jmp() function. This is not 
always
++   the case. Some newer glibc versions rewrote raise() and now t