Control: tags 995393 + pending
Control: tags 1001961 + pending

Dear maintainer,

to finally address the segfault issue on ppc64el, I've prepared and NMU
for fakeroot (versioned as 1.26-1.2), and uploaded it to DELAYED/3.
Please feel free to tell me if I should delay it longer.


diff -Nru fakeroot-1.26/debian/changelog fakeroot-1.26/debian/changelog
--- fakeroot-1.26/debian/changelog      2021-12-23 08:19:30.000000000 +0100
+++ fakeroot-1.26/debian/changelog      2022-01-03 18:49:27.000000000 +0100
@@ -1,3 +1,10 @@
+fakeroot (1.26-1.2) unstable; urgency=high
+
+  * Non-maintainer upload
+  * Fix segfault on ppc64el, take 2. Closes: #995393
+
+ -- Christoph Biedl <debian.a...@manchmal.in-ulm.de>  Mon, 03 Jan 2022 
18:49:27 +0100
+
 fakeroot (1.26-1.1) unstable; urgency=high
 
   * Non-maintainer upload
diff -Nru fakeroot-1.26/debian/patches/fix-prototype-generation.patch 
fakeroot-1.26/debian/patches/fix-prototype-generation.patch
--- fakeroot-1.26/debian/patches/fix-prototype-generation.patch 1970-01-01 
01:00:00.000000000 +0100
+++ fakeroot-1.26/debian/patches/fix-prototype-generation.patch 2022-01-03 
12:55:03.000000000 +0100
@@ -0,0 +1,59 @@
+Subject: Fix prototype generation for openat
+Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
+Date: 2021-12-30
+Bug-Debian: https://bugs.debian.org/995393
+Forwarded: Yes (implicitely)
+
+    As jrtc27 pointed out in IRC, ppc64el is more strict than other
+    architectures when it comes to va_arg handling:
+
+        it's that ppc64le uses the elfv2 abi, and for variadic calls you
+        must reserve space for a parameter save area
+
+    So enhance wrapawk to create a proper prototype and argument
+    handling although it's specific to the openat call. Also add the
+    missing documentation for the sixth column to wrapfunc.inp.
+
+--- a/wrapawk
++++ b/wrapawk
+@@ -37,7 +37,25 @@
+   argtype=$3;
+   argname=$4;
+   MACRO=$5;
+-  if(MACRO){
++  openat_extra=$6;
++  if(openat_extra){
++    print "  {(void(*))&next_" name ", \"" name "\"},"  > structfile;
++    print "extern " ret " (*next_" name ")" openat_extra ";" > headerfile;
++    print ret " (*next_" name ")" openat_extra "=tmp_" name ";"> deffile;
++
++    print ret " tmp_" name,  openat_extra "{"           > tmpffile;
++    print "  mode_t mode = 0;"                          > tmpffile;
++    print "  if (flags & O_CREAT) {"                    > tmpffile;
++    print "    va_list args;"                           > tmpffile;
++    print "    va_start(args, flags);"                  > tmpffile;
++    print "    mode = va_arg(args, int);"               > tmpffile;
++    print "    va_end(args);"                           > tmpffile;
++    print "  }"                                         > tmpffile;
++    print "  load_library_symbols();"                   > tmpffile;
++    print "  return  next_" name,  argname ";"          > tmpffile;
++    print "}"                                           > tmpffile;
++    print ""                                            > tmpffile;
++  } else if(MACRO){
+     print "  {(void(*))&NEXT_" MACRO "_NOARG, " name "_QUOTE},"  > structfile;
+     print "extern " ret " (*NEXT_" MACRO "_NOARG)" argtype ";" > headerfile;
+     print ret " (*NEXT_" MACRO "_NOARG)" argtype "=TMP_" MACRO ";"> deffile;
+--- a/wrapfunc.inp
++++ b/wrapfunc.inp
+@@ -9,8 +9,10 @@
+ /**/                                                                    */
+ /* each line of this file lists 4 fields, seperated by a ";".           */
+ /* The first field is the name of the wrapped function, then it's return  */
+-/* value. After that come the function arguments with types, and the last */
++/* value. After that come the function arguments with types, and the fifth */
+ /* field contains the function arguments without types.                   */
++/* A sixth field is a special needed when wrapping the openat syscall.    */
++/* Otherwise it's like the third (function arguments with types).         */
+ /**/
+ 
+ /* __*xstat are used on glibc systems instead of just *xstat. */
diff -Nru fakeroot-1.26/debian/patches/ppc64el-workaround.patch 
fakeroot-1.26/debian/patches/ppc64el-workaround.patch
--- fakeroot-1.26/debian/patches/ppc64el-workaround.patch       2021-12-23 
08:19:30.000000000 +0100
+++ fakeroot-1.26/debian/patches/ppc64el-workaround.patch       1970-01-01 
01:00:00.000000000 +0100
@@ -1,31 +0,0 @@
-Subject: Work around segfault on ppc64el
-Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
-Date: 2021-12-20
-Bug-Debian: https://bugs.debian.org/995393
-Forwarded: Yes
-
-    For whatever reason the generated code segfaults on ppc64el when
-    built with the usual optimizations. The root cause is not clear,
-    might be a compiler bug or the result of improperly generated
-    function prototypes.
-
-    As a workaround, disable optimizations for the affected function.
-
-    This should be re-visted upon any major compiler release whether
-    it's still needed.
-
---- a/libfakeroot.c
-+++ b/libfakeroot.c
-@@ -2596,7 +2596,11 @@
- #endif
- 
- #ifdef HAVE_OPENAT
--int openat(int dir_fd, const char *pathname, int flags, ...)
-+int
-+#if defined(__powerpc__) && defined(__powerpc64__) && __BYTE_ORDER__ == 
__ORDER_LITTLE_ENDIAN__
-+__attribute__((optimize("O0")))
-+#endif
-+openat(int dir_fd, const char *pathname, int flags, ...)
- {
-       mode_t mode;
- 
diff -Nru fakeroot-1.26/debian/patches/series 
fakeroot-1.26/debian/patches/series
--- fakeroot-1.26/debian/patches/series 2021-12-23 08:18:30.000000000 +0100
+++ fakeroot-1.26/debian/patches/series 2021-12-30 19:05:37.000000000 +0100
@@ -1,3 +1,3 @@
 fix-shell-in-fakeroot
 also-wrap-stat-library-call.patch
-ppc64el-workaround.patch
+fix-prototype-generation.patch
diff -Nru fakeroot-1.26/debian/rules fakeroot-1.26/debian/rules
--- fakeroot-1.26/debian/rules  2021-12-22 19:24:26.000000000 +0100
+++ fakeroot-1.26/debian/rules  2022-01-02 22:39:58.000000000 +0100
@@ -62,7 +62,7 @@
        echo /$(LIB_DIR)/libfakeroot > 
debian/tmp/etc/ld.so.conf.d/fakeroot-$(DEB_HOST_MULTIARCH).conf
 
 override_dh_auto_clean:
-       rm -rf obj-sysv obj-tcp
+       rm -rf obj-sysv obj-tcp wrapdef.h wrapstruct.h
        dh_autoreconf_clean
        rm -f dhar-stamp
        $(RM) debian/fakeroot.postinst

Attachment: signature.asc
Description: PGP signature

Reply via email to