Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 345001

Summary: app-editors/emacs-23.2-r2 fails to build (won't "dump") on arm
Product: Gentoo Linux Reporter: Josh Parsons <josh.parsons>
Component: Current packagesAssignee: Emacs project <emacs>
Status: RESOLVED NEEDINFO    
Severity: major CC: arm
Priority: High    
Version: unspecified   
Hardware: ARM   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: complete build.log for the failed emerge
Kernel config - gentoo hardened.

Description Josh Parsons 2010-11-11 03:45:16 UTC
Building emacs involves a procedure called "dumping" where an emacs process saves a copy of its own heap for incorporation into the final emacs binary installed. This is obviously very sensitive to differences between architectures, and seems not to work for me on my armv5te (openrd) system. Details below. The same version of emacs causes no problems on my x86, amd64 and ppc systems; earlier stable versions of emacs worked on the arm system.

Reproducible: Always

Steps to Reproduce:
emerge app-editors/emacs
Actual Results:  
...
Dumping under the name emacs
**************************************************
Warning: Your system has a gap between BSS and the
heap (20522492 bytes).  This usually means that exec-shield
or something similar is in effect.  The dump may
fail because of this.  See the section about
exec-shield in etc/PROBLEMS for more information.
**************************************************
make[1]: *** [bootstrap-emacs] Segmentation fault
make[1]: Leaving directory `/var/tmp/portage/app-editors/emacs-23.2-r2/work/emacs-23.2/src'
make: *** [src] Error 2



Portage 2.1.8.3 (default/linux/arm/10.0/server, gcc-4.4.4, glibc-2.11.2-r3, 2.6.36-gentoo armv5tel)
=================================================================
                        System Settings
=================================================================
System uname: Linux-2.6.36-gentoo-armv5tel-Feroceon_88FR131_rev_1_-v5l-with-gentoo-1.12.13
Timestamp of tree: Wed, 10 Nov 2010 12:15:01 +0000
distcc 3.1 armv5tel-softfloat-linux-gnueabi [disabled]
ccache version 2.4 [enabled]
app-shells/bash:     4.1_p7
dev-lang/python:     2.6.5-r3, 3.1.2-r3
dev-util/ccache:     2.4-r7
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    2.3-r1
sys-devel/autoconf:  2.65-r1
sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.4-r2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.34
ACCEPT_KEYWORDS="arm"
ACCEPT_LICENSE="*"
CBUILD="armv5tel-softfloat-linux-gnueabi"
CFLAGS="-O2 -march=armv5te -mtune=xscale -pipe -DG_DISABLE_CAST_CHECKS"
CHOST="armv5tel-softfloat-linux-gnueabi"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=armv5te -mtune=xscale -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests ccache distlocks fixpackages news parallel-fetch protect-owned sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo-distfiles.mirrors.tds.net/"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS=""
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/pro-audio /usr/portage/local/layman/x11 /usr/portage/local/layman/multimedia /usr/portage/local/misc"
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"
USE="X a52 aac acl alsa arm berkdb bluetooth bzip2 cli cracklib crypt cups cxx dbus emacs enca extras faac faad fasttrack ffmpeg flac fortran gdbm gif git gnutella gnutls gpm gtk iconv inotify ipv6 jpeg ldap lzo mad magic matroska mmap modules mp3 mpeg mudflap mysql ncurses network nptl nptlonly ogg openmp pam pcre perl png pppd python readline rrdcgi server session snmp sqlite ssl subversion svg sysfs syslog tcpd tiff toolkit-scroll-bars truetype unicode utils v4l2 vorbis xcb xinetd xml xorg xvid zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="dummy fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Josh Parsons 2010-11-11 03:46:05 UTC
Created attachment 253951 [details]
complete build.log for the failed emerge
Comment 2 Ulrich Müller gentoo-dev 2010-11-11 10:28:00 UTC
That's an old issue (and I thought is was fixed).

You may have a look at these:
<http://lkml.org/lkml/2007/10/23/435>
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=900>
Bug 236579

What is the output of the following command?
$ cat /proc/sys/kernel/randomize_va_space

Comment 3 Markus Meier gentoo-dev 2010-11-12 12:55:39 UTC
I'm unable to reproduce this, I used the same CFLAGS and USE-flags but could not trigger it.

# cat /proc/sys/kernel/randomize_va_space
1
Comment 4 Josh Parsons 2010-11-13 05:35:26 UTC
# cat /proc/sys/kernel/randomize_va_space
2

Oh, and I made a mistake in my initial report. Earlier versions of emacs no longer build for me on the affected machine, though I'm not sure what I changed to cause this. I am running a fairly recent kernel: gentoo-sources-2.6.36. Previous builds would have been under a different kernel.

Oh, and CONFIG_COMPAT_BRK is not set for my kernel if that makes a difference.

I assumed that the relevant difference between the machine which is having trouble and my other machines was architecture. It may be that the difference is that they are not running a 2.6.36 kernel (which they aren't), or there is some subtle configuration difference.

Comment 5 Ulrich Müller gentoo-dev 2010-11-13 10:10:46 UTC
(In reply to comment #4)
> # cat /proc/sys/kernel/randomize_va_space
> 2

Does Emacs build if you set this to 0 or 1? ("echo 0 >/proc/sys/kernel/randomize_va_space", and verify that it really contains that value afterwards.)

But in principle, Emacs should do that by itself, i.e. before dumping, it should set a different process personality and then execvp itself. See lines 879 and following in emacs.c:

#ifdef HAVE_PERSONALITY_LINUX32
  if (!initialized
      && (strcmp (argv[argc-1], "dump") == 0
          || strcmp (argv[argc-1], "bootstrap") == 0)
      && ! getenv ("EMACS_HEAP_EXEC"))
    {
      /* Set this so we only do this once.  */
      putenv("EMACS_HEAP_EXEC=true");

      /* A flag to turn off address randomization which is introduced
         in linux kernel shipped with fedora core 4 */
#define ADD_NO_RANDOMIZE 0x0040000
      personality (PER_LINUX32 | ADD_NO_RANDOMIZE);
#undef  ADD_NO_RANDOMIZE

      execvp (argv[0], argv);

      /* If the exec fails, try to dump anyway.  */
      perror ("execvp");
    }
#endif /* HAVE_PERSONALITY_LINUX32 */

> I am running a fairly recent kernel: gentoo-sources-2.6.36. Previous builds
> would have been under a different kernel.
> 
> Oh, and CONFIG_COMPAT_BRK is not set for my kernel if that makes a
> difference.

I can't speak for arm, but on amd64 that combination (2.6.36 without COMPAT_BRK) works.
Comment 6 Josh Parsons 2010-11-13 21:50:15 UTC
Builds OK with /proc/sys/kernel/randomize_va_space=1
Comment 7 Christian Speckner 2011-08-22 08:51:17 UTC
I can confirm this problem as well as the solution of disabling address randomization on a SheevaPlug ARM system with emacs-23.3-r1 and vanilla-sources-2.6.37.6. It used to work before, and was a kernel update in between (from 2.6.32.9 if I remember correctly), so I wonder whether this might really be kernel problem along the lines of disabling randomization by changing personality being broken. I'll try to investigate this a bit more when I find time.
Comment 8 Ulrich Müller gentoo-dev 2011-08-22 10:19:30 UTC
That's the sort of problem that usually needs to be debugged on the platform where it fails. Any help on this bug will be appreciated.
Comment 9 perillamint 2015-05-10 17:54:19 UTC
Created attachment 402976 [details]
Kernel config - gentoo hardened.

It also fails on AMD64 hardened kernel (Note: Kernel version linux-3.19.6-hardened-r1. Only kernel is hardened. I'm using normal systemd profile). It complains about exec-shield and segfaults after complaining.

I think it is related on grsecurity setting, so I attach my kernel config

and here is my dmesg.

[423293.428710] temacs[15435]: segfault at af7008 ip 00000373135c4970 sp 000003af446f5cb8 error 4 in libc-2.20.so[37313533000+18f000]
[423537.191298] temacs[20282]: segfault at af7008 ip 0000032846f06970 sp 000003908abfbaa8 error 4 in libc-2.20.so[32846e75000+18f000]
Comment 10 Ulrich Müller gentoo-dev 2015-05-10 18:04:29 UTC
(In reply to perillamint from comment #9)

Different architecture, and given the time that has passed, it is likely a different issue.

Please file a new bug and attach your build.log there.
Comment 11 Ulrich Müller gentoo-dev 2015-05-10 18:38:45 UTC
No progress since 2011. Closing.
Comment 12 Josh Parsons 2015-05-10 21:23:50 UTC
For what it's worth, if anyone is following this, the hardware on which I had the problem gave up the ghost in Jan 2015. I had for 5 years had an init script that contained "echo 1 >/proc/sys/kernel/randomize_va_space".