bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#20614: Segmentation fault when building on Power8 Little Endian


From: Petr Hracek
Subject: bug#20614: Segmentation fault when building on Power8 Little Endian
Date: Mon, 5 Oct 2015 13:23:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 10/05/2015 11:39 AM, Eli Zaretskii wrote:
Cc: 20614@debbugs.gnu.org
From: Petr Hracek <phracek@redhat.com>
Date: Mon, 5 Oct 2015 11:16:32 +0200

(gdb) p old_section_names + NEW_SECTION_H (nn).sh_name
$2 = 0x4000128ceb51 <Address 0x4000128ceb51 out of bounds>
We have a function valid_pointer_p in alloc.c.  What happens if you
use the same code in unexec, before the series of calls to strcmp that
crash, and only proceed to call strcmp if valid_pointer_p returns a
positive value?
I have no problem to do it.
I have made a this patch against emacs-24.3
diff --git a/src/unexelf.c b/src/unexelf.c
index d365940..677a1af 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -389,6 +389,7 @@ temacs:
 #include <unexec.h>

 extern void fatal (const char *msgid, ...);
+extern int valid_pointer_p (void *);

 #include <sys/types.h>
 #include <stdint.h>
@@ -845,8 +846,7 @@ unexec (const char *new_name, const char *old_name)
       ElfW (Word) alignment = (NEW_PROGRAM_H (n)).p_align;
       if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
     alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
-
-#ifdef __sgi
+#if defined __sgi || defined __powerpc64__
       /* According to r02kar@x4u2.desy.de (Karsten Kuenne)
          and oliva@gnu.org (Alexandre Oliva), on IRIX 5.2, we
          always get "Program segment above .bss" when dumping
@@ -866,8 +866,10 @@ unexec (const char *new_name, const char *old_name)
           == round_up (old_bss_addr, alignment)))
     break;
     }
+#ifndef __powerpc64__
   if (n < 0)
     fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0);
+#endif

   /* Make sure that the size includes any padding before the old .bss
      section.  */
@@ -1251,6 +1253,12 @@ temacs:
          be no harm in that provided that r_offset is always the first
          member.  */
       nn = section.sh_info;
+      valid_pointer_p (old_section_names + NEW_SECTION_H (nn).sh_name);
if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
           || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
               ".sdata")

But if fails with
/home/phracek/rpmbuild/BUILD/emacs-24.3/src/unexelf.c:1263: undefined reference to `valid_pointer_p'
collect2: error: ld returned 1 exit status
make[2]: *** [temacs] Error 1
make[2]: Leaving directory `/home/phracek/rpmbuild/BUILD/emacs-24.3/src'
make[1]: *** [src] Error 2
make[1]: Leaving directory `/home/phracek/rpmbuild/BUILD/emacs-24.3'
make: *** [bootstrap] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.QoDw34 (%build)

--
Petr Hracek
Software Engineer
Developer Experience
Red Hat, Inc
Mob: +420777056169
email: phracek@redhat.com






reply via email to

[Prev in Thread] Current Thread [Next in Thread]