# Apache failing to start with "Stack smashing detected"

## Havin_it

Hi,

Thought I'd put this here before bugging bugzilla, in case I'm just being thick. I just tried to fire up apache-2.2.22-r1 on my laptop, where it's always been installed but never used before. The configs are still in untouched, OOTB state. This is what happened:

```
minime ~ # /etc/init.d/apache2 start

*** stack smashing detected ***: /usr/sbin/apache2 terminated

======= Backtrace: =========

/lib/libc.so.6(__fortify_fail+0x50)[0xb73d14c0]

/lib/libc.so.6(+0xec46a)[0xb73d146a]

/usr/sbin/apache2[0x809cef4]

/usr/sbin/apache2[0x806cf0a]

======= Memory map: ========

08048000-080a7000 r-xp 00000000 08:01 18184      /usr/sbin/apache2

080a8000-080a9000 r--p 0005f000 08:01 18184      /usr/sbin/apache2

080a9000-080ab000 rw-p 00060000 08:01 18184      /usr/sbin/apache2

080ab000-080ae000 rw-p 00000000 00:00 0 

0999d000-099e0000 rw-p 00000000 00:00 0          [heap]

b72e3000-b72e5000 rw-p 00000000 00:00 0 

b72e5000-b7442000 r-xp 00000000 08:01 746272     /lib/libc-2.14.1.so

b7442000-b7444000 r--p 0015d000 08:01 746272     /lib/libc-2.14.1.so

b7444000-b7445000 rw-p 0015f000 08:01 746272     /lib/libc-2.14.1.so

b7445000-b7448000 rw-p 00000000 00:00 0 

b7448000-b744a000 r-xp 00000000 08:01 746261     /lib/libdl-2.14.1.so

b744a000-b744b000 r--p 00001000 08:01 746261     /lib/libdl-2.14.1.so

b744b000-b744c000 rw-p 00002000 08:01 746261     /lib/libdl-2.14.1.so

b744c000-b7462000 r-xp 00000000 08:01 641200     /lib/libpthread-2.14.1.so

b7462000-b7463000 r--p 00015000 08:01 641200     /lib/libpthread-2.14.1.so

b7463000-b7464000 rw-p 00016000 08:01 641200     /lib/libpthread-2.14.1.so

b7464000-b7467000 rw-p 00000000 00:00 0 

b7467000-b746f000 r-xp 00000000 08:01 583090     /lib/libcrypt-2.14.1.so

b746f000-b7470000 r--p 00007000 08:01 583090     /lib/libcrypt-2.14.1.so

b7470000-b7471000 rw-p 00008000 08:01 583090     /lib/libcrypt-2.14.1.so

b7471000-b7498000 rw-p 00000000 00:00 0 

b7498000-b749f000 r-xp 00000000 08:01 746266     /lib/librt-2.14.1.so

b749f000-b74a0000 r--p 00006000 08:01 746266     /lib/librt-2.14.1.so                                                           

b74a0000-b74a1000 rw-p 00007000 08:01 746266     /lib/librt-2.14.1.so                                                           

b74a1000-b74a5000 r-xp 00000000 08:01 528237     /lib/libuuid.so.1.3.0                                                          

b74a5000-b74a6000 r--p 00003000 08:01 528237     /lib/libuuid.so.1.3.0

b74a6000-b74a7000 rw-p 00004000 08:01 528237     /lib/libuuid.so.1.3.0

b74a7000-b74d6000 r-xp 00000000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74d6000-b74d7000 r--p 0002e000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74d7000-b74d8000 rw-p 0002f000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74d8000-b7501000 r-xp 00000000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7501000-b7502000 ---p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7502000-b7504000 r--p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7504000-b7505000 rw-p 0002b000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7505000-b750c000 r-xp 00000000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b750c000-b750d000 r--p 00006000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b750d000-b750e000 rw-p 00007000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b750e000-b750f000 rw-p 00000000 00:00 0 

b750f000-b7691000 r-xp 00000000 08:01 13413      /usr/lib/libdb-4.8.so

b7691000-b7693000 r--p 00181000 08:01 13413      /usr/lib/libdb-4.8.so

b7693000-b7695000 rw-p 00183000 08:01 13413      /usr/lib/libdb-4.8.so

b7695000-b76b7000 r-xp 00000000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76b7000-b76b8000 r--p 00021000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76b8000-b76b9000 rw-p 00022000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76b9000-b7712000 r-xp 00000000 08:01 527879     /lib/libpcre.so.1.0.0

b7712000-b7713000 r--p 00059000 08:01 527879     /lib/libpcre.so.1.0.0

b7713000-b7714000 rw-p 0005a000 08:01 527879     /lib/libpcre.so.1.0.0

b7714000-b7738000 r-xp 00000000 08:01 583084     /lib/libm-2.14.1.so

b7738000-b7739000 r--p 00023000 08:01 583084     /lib/libm-2.14.1.so

b7739000-b773a000 rw-p 00024000 08:01 583084     /lib/libm-2.14.1.so

b7740000-b7759000 r-xp 00000000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7759000-b775a000 r--p 00018000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b775a000-b775b000 rw-p 00019000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b775b000-b775d000 rw-p 00000000 00:00 0 

b775d000-b775e000 r-xp 00000000 00:00 0          [vdso]

b775e000-b777b000 r-xp 00000000 08:01 746271     /lib/ld-2.14.1.so

b777b000-b777c000 r--p 0001c000 08:01 746271     /lib/ld-2.14.1.so

b777c000-b777d000 rw-p 0001d000 08:01 746271     /lib/ld-2.14.1.so

bfeb7000-bfed8000 rw-p 00000000 00:00 0          [stack]

/etc/init.d/apache2: line 60: 12402 Aborted                 ${APACHE2} ${APACHE2_OPTS} -t > /dev/null 2>&1

 * apache2 has detected an error in your setup:

*** stack smashing detected ***: /usr/sbin/apache2 terminated

======= Backtrace: =========

/lib/libc.so.6(__fortify_fail+0x50)[0xb73f34c0]

/lib/libc.so.6(+0xec46a)[0xb73f346a]

/usr/sbin/apache2[0x809cef4]

/usr/sbin/apache2[0x806cf0a]

======= Memory map: ========

08048000-080a7000 r-xp 00000000 08:01 18184      /usr/sbin/apache2

080a8000-080a9000 r--p 0005f000 08:01 18184      /usr/sbin/apache2

080a9000-080ab000 rw-p 00060000 08:01 18184      /usr/sbin/apache2

080ab000-080ae000 rw-p 00000000 00:00 0 

096d0000-09713000 rw-p 00000000 00:00 0          [heap]

b7305000-b7307000 rw-p 00000000 00:00 0 

b7307000-b7464000 r-xp 00000000 08:01 746272     /lib/libc-2.14.1.so

b7464000-b7466000 r--p 0015d000 08:01 746272     /lib/libc-2.14.1.so

b7466000-b7467000 rw-p 0015f000 08:01 746272     /lib/libc-2.14.1.so

b7467000-b746a000 rw-p 00000000 00:00 0 

b746a000-b746c000 r-xp 00000000 08:01 746261     /lib/libdl-2.14.1.so

b746c000-b746d000 r--p 00001000 08:01 746261     /lib/libdl-2.14.1.so

b746d000-b746e000 rw-p 00002000 08:01 746261     /lib/libdl-2.14.1.so

b746e000-b7484000 r-xp 00000000 08:01 641200     /lib/libpthread-2.14.1.so

b7484000-b7485000 r--p 00015000 08:01 641200     /lib/libpthread-2.14.1.so

b7485000-b7486000 rw-p 00016000 08:01 641200     /lib/libpthread-2.14.1.so

b7486000-b7489000 rw-p 00000000 00:00 0 

b7489000-b7491000 r-xp 00000000 08:01 583090     /lib/libcrypt-2.14.1.so

b7491000-b7492000 r--p 00007000 08:01 583090     /lib/libcrypt-2.14.1.so

b7492000-b7493000 rw-p 00008000 08:01 583090     /lib/libcrypt-2.14.1.so

b7493000-b74ba000 rw-p 00000000 00:00 0 

b74ba000-b74c1000 r-xp 00000000 08:01 746266     /lib/librt-2.14.1.so

b74c1000-b74c2000 r--p 00006000 08:01 746266     /lib/librt-2.14.1.so

b74c2000-b74c3000 rw-p 00007000 08:01 746266     /lib/librt-2.14.1.so

b74c3000-b74c7000 r-xp 00000000 08:01 528237     /lib/libuuid.so.1.3.0

b74c7000-b74c8000 r--p 00003000 08:01 528237     /lib/libuuid.so.1.3.0

b74c8000-b74c9000 rw-p 00004000 08:01 528237     /lib/libuuid.so.1.3.0

b74c9000-b74f8000 r-xp 00000000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74f8000-b74f9000 r--p 0002e000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74f9000-b74fa000 rw-p 0002f000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b74fa000-b7523000 r-xp 00000000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7523000-b7524000 ---p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7524000-b7526000 r--p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7526000-b7527000 rw-p 0002b000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7527000-b752e000 r-xp 00000000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b752e000-b752f000 r--p 00006000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b752f000-b7530000 rw-p 00007000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b7530000-b7531000 rw-p 00000000 00:00 0 

b7531000-b76b3000 r-xp 00000000 08:01 13413      /usr/lib/libdb-4.8.so

b76b3000-b76b5000 r--p 00181000 08:01 13413      /usr/lib/libdb-4.8.so

b76b5000-b76b7000 rw-p 00183000 08:01 13413      /usr/lib/libdb-4.8.so

b76b7000-b76d9000 r-xp 00000000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76d9000-b76da000 r--p 00021000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76da000-b76db000 rw-p 00022000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b76db000-b7734000 r-xp 00000000 08:01 527879     /lib/libpcre.so.1.0.0

b7734000-b7735000 r--p 00059000 08:01 527879     /lib/libpcre.so.1.0.0

b7735000-b7736000 rw-p 0005a000 08:01 527879     /lib/libpcre.so.1.0.0

b7736000-b775a000 r-xp 00000000 08:01 583084     /lib/libm-2.14.1.so

b775a000-b775b000 r--p 00023000 08:01 583084     /lib/libm-2.14.1.so

b775b000-b775c000 rw-p 00024000 08:01 583084     /lib/libm-2.14.1.so

b7762000-b777b000 r-xp 00000000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b777b000-b777c000 r--p 00018000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b777c000-b777d000 rw-p 00019000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b777d000-b777f000 rw-p 00000000 00:00 0 

b777f000-b7780000 r-xp 00000000 00:00 0          [vdso]

b7780000-b779d000 r-xp 00000000 08:01 746271     /lib/ld-2.14.1.so

b779d000-b779e000 r--p 0001c000 08:01 746271     /lib/ld-2.14.1.so

b779e000-b779f000 rw-p 0001d000 08:01 746271     /lib/ld-2.14.1.so

bfcda000-bfcfb000 rw-p 00000000 00:00 0          [stack]

/etc/init.d/apache2: line 60: 12404 Aborted                 ${APACHE2} ${APACHE2_OPTS} -t

 * ERROR: apache2 failed to start
```

I've reinstalled apache, apache-tools, apr and apr-util, and done a revdep-rebuild, to no avail. I'm currently on glibc-2.14.1-r2 (upgrade to 2.15-r1 build is failing atm). Kernels gentoo-sources-3.3.0 and 3.3.3 tried. I haven't set anything non-default regarding stack-smashing protection.

Would welcome any ideas why this is happening and what to do about it, before I go embarrass myself again on bugzilla   :Embarassed: 

----------

## audiodef

Hm... https://en.wikipedia.org/wiki/Stack_buffer_overflow

I've never had this problem. Does it happen when you try a different (upgrade or downgrade) version of Apache?

----------

## Havin_it

 *audiodef wrote:*   

> Hm... https://en.wikipedia.org/wiki/Stack_buffer_overflow
> 
> I've never had this problem. Does it happen when you try a different (upgrade or downgrade) version of Apache?

 

Yeah, I started with apache-2.4.1 (incredibly, this error got in before all the other many ways in which that release can crap out on launch!), then went down to 2.2.22 and now 2.2.22-r1. I've got the same version running quite happily (and with a lot more complex config and more modules) on my amd64 Gentoo box.

----------

## cach0rr0

rebuild apache with FEATURES="splitdebug"

run it under gdb

i.e.

```

gdb /usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -k start

```

adjust the -D above to match your /etc/conf.d/apache2

it could be one of the linked in modules that's causing an issue. If you want to skip the gdb route for now, comment out different -D in your /etc/conf.d/apache2 and prune it down to a bare minimum, keep trying to restart apache. If it fails without any args, it's apache itself. If removing, say, -D SSL sorts the issue, that's where you look

----------

## Havin_it

OK, I ran it under gdb as follows:

```
minime linux # gdb /usr/sbin/apache2

GNU gdb (Gentoo 7.4 p1) 7.4

Copyright (C) 2012 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "i686-pc-linux-gnu".

For bug reporting instructions, please see:

<http://bugs.gentoo.org/>...

Reading symbols from /usr/sbin/apache2...Reading symbols from /usr/lib/debug/usr/sbin/apache2.debug...(no debugging symbols found)...done.

(no debugging symbols found)...done.

(gdb) run -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start

Starting program: /usr/sbin/apache2 -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/libthread_db.so.1".

*** stack smashing detected ***: /usr/sbin/apache2 terminated

======= Backtrace: =========

/lib/libc.so.6(__fortify_fail+0x50)[0xb7c544c0]

/lib/libc.so.6(+0xec46a)[0xb7c5446a]

/usr/sbin/apache2[0x809cef4]

/usr/sbin/apache2[0x806cf0a]

======= Memory map: ========

08048000-080a7000 r-xp 00000000 08:01 18194      /usr/sbin/apache2

080a8000-080a9000 r--p 0005f000 08:01 18194      /usr/sbin/apache2

080a9000-080ab000 rw-p 00060000 08:01 18194      /usr/sbin/apache2

080ab000-080f1000 rw-p 00000000 00:00 0          [heap]

b7b66000-b7b68000 rw-p 00000000 00:00 0 

b7b68000-b7cc5000 r-xp 00000000 08:01 746272     /lib/libc-2.14.1.so

b7cc5000-b7cc7000 r--p 0015d000 08:01 746272     /lib/libc-2.14.1.so

b7cc7000-b7cc8000 rw-p 0015f000 08:01 746272     /lib/libc-2.14.1.so

b7cc8000-b7ccb000 rw-p 00000000 00:00 0 

b7ccb000-b7ccd000 r-xp 00000000 08:01 746261     /lib/libdl-2.14.1.so

b7ccd000-b7cce000 r--p 00001000 08:01 746261     /lib/libdl-2.14.1.so

b7cce000-b7ccf000 rw-p 00002000 08:01 746261     /lib/libdl-2.14.1.so

b7ccf000-b7ce5000 r-xp 00000000 08:01 641200     /lib/libpthread-2.14.1.so

b7ce5000-b7ce6000 r--p 00015000 08:01 641200     /lib/libpthread-2.14.1.so

b7ce6000-b7ce7000 rw-p 00016000 08:01 641200     /lib/libpthread-2.14.1.so

b7ce7000-b7cea000 rw-p 00000000 00:00 0 

b7cea000-b7cf2000 r-xp 00000000 08:01 583090     /lib/libcrypt-2.14.1.so

b7cf2000-b7cf3000 r--p 00007000 08:01 583090     /lib/libcrypt-2.14.1.so

b7cf3000-b7cf4000 rw-p 00008000 08:01 583090     /lib/libcrypt-2.14.1.so

b7cf4000-b7d1b000 rw-p 00000000 00:00 0 

b7d1b000-b7d22000 r-xp 00000000 08:01 746266     /lib/librt-2.14.1.so

b7d22000-b7d23000 r--p 00006000 08:01 746266     /lib/librt-2.14.1.so

b7d23000-b7d24000 rw-p 00007000 08:01 746266     /lib/librt-2.14.1.so

b7d24000-b7d28000 r-xp 00000000 08:01 528237     /lib/libuuid.so.1.3.0

b7d28000-b7d29000 r--p 00003000 08:01 528237     /lib/libuuid.so.1.3.0

b7d29000-b7d2a000 rw-p 00004000 08:01 528237     /lib/libuuid.so.1.3.0

b7d2a000-b7d59000 r-xp 00000000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b7d59000-b7d5a000 r--p 0002e000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b7d5a000-b7d5b000 rw-p 0002f000 08:01 18122      /usr/lib/libapr-1.so.0.4.6

b7d5b000-b7d84000 r-xp 00000000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7d84000-b7d85000 ---p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7d85000-b7d87000 r--p 00029000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7d87000-b7d88000 rw-p 0002b000 08:01 2438       /usr/lib/libexpat.so.1.6.0

b7d88000-b7d8f000 r-xp 00000000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b7d8f000-b7d90000 r--p 00006000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b7d90000-b7d91000 rw-p 00007000 08:01 7618       /usr/lib/libgdbm.so.4.0.0

b7d91000-b7d92000 rw-p 00000000 00:00 0 

b7d92000-b7f14000 r-xp 00000000 08:01 13413      /usr/lib/libdb-4.8.so

b7f14000-b7f16000 r--p 00181000 08:01 13413      /usr/lib/libdb-4.8.so

b7f16000-b7f18000 rw-p 00183000 08:01 13413      /usr/lib/libdb-4.8.so

b7f18000-b7f3a000 r-xp 00000000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b7f3a000-b7f3b000 r--p 00021000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b7f3b000-b7f3c000 rw-p 00022000 08:01 18168      /usr/lib/libaprutil-1.so.0.4.1

b7f3c000-b7f95000 r-xp 00000000 08:01 527879     /lib/libpcre.so.1.0.0

b7f95000-b7f96000 r--p 00059000 08:01 527879     /lib/libpcre.so.1.0.0

b7f96000-b7f97000 rw-p 0005a000 08:01 527879     /lib/libpcre.so.1.0.0

b7f97000-b7fbb000 r-xp 00000000 08:01 583084     /lib/libm-2.14.1.so

b7fbb000-b7fbc000 r--p 00023000 08:01 583084     /lib/libm-2.14.1.so

b7fbc000-b7fbd000 rw-p 00024000 08:01 583084     /lib/libm-2.14.1.so

b7fc3000-b7fdc000 r-xp 00000000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7fdc000-b7fdd000 r--p 00018000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7fdd000-b7fde000 rw-p 00019000 08:01 437856     /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7fde000-b7fe0000 rw-p 00000000 00:00 0 

b7fe0000-b7fe1000 r-xp 00000000 00:00 0          [vdso]

b7fe1000-b7ffe000 r-xp 00000000 08:01 746271     /lib/ld-2.14.1.so

b7ffe000-b7fff000 r--p 0001c000 08:01 746271     /lib/ld-2.14.1.so

b7fff000-b8000000 rw-p 0001d000 08:01 746271     /lib/ld-2.14.1.so

bffdf000-c0000000 rw-p 00000000 00:00 0          [stack]

Program received signal SIGABRT, Aborted.

0xb7fe0424 in __kernel_vsyscall ()

(gdb) bt

#0  0xb7fe0424 in __kernel_vsyscall ()

#1  0xb7b96222 in raise () from /lib/libc.so.6

#2  0xb7b97a1e in abort () from /lib/libc.so.6

#3  0xbfffe420 in ?? ()

Backtrace stopped: previous frame inner to this frame (corrupt stack?)

(gdb) quit

A debugging session is active.

        Inferior 1 [process 15788] will be killed.

Quit anyway? (y or n) y
```

Same results with or without various -D options. From the above, it looks like something's not right with the splitdebug feature: /usr/lib/debug/usr/sbin/apache2 does exist, but it's claiming no symbols found...?

I'll try rebuilding glibc with FEATURES=splitdebug too, since that seems to be the source of the problem.

----------

## Havin_it

Now this is interesting: when I try to build glibc-2.15-r1 (an upgrade from the current version), the errors at the build failure appear to be to do with stack-protection:

```
/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os: In function `check_one_fd':

check_fds.c:(.text+0x16c74): undefined reference to `__stack_chk_fail_local'

/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os: In function `__libc_check_standard_fds':

(.text+0x16cf8): undefined reference to `__stack_chk_fail_local'

/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os: In function `__udivmoddi4':

divdi3.c:(.text+0x16ec4): undefined reference to `__stack_chk_fail_local'

/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os: In function `__divdi3_internal':

(.text+0x16f6a): undefined reference to `__stack_chk_fail_local'

/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os: In function `__moddi3_internal':

(.text+0x17040): undefined reference to `__stack_chk_fail_local'

/dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/librtld.os:(.text+0x1709d): more undefined references to `__stack_chk_fail_local' follow

/usr/lib/gcc/i686-pc-linux-gnu/4.5.3/../../../../i686-pc-linux-gnu/bin/ld: /dev/shm/portage/sys-libs/glibc-2.15-r1/work/build-default-i686-pc-linux-gnu-nptl/elf/ld.so: hidden symbol `__stack_chk_fail_local' isn't defined

/usr/lib/gcc/i686-pc-linux-gnu/4.5.3/../../../../i686-pc-linux-gnu/bin/ld: final link failed: Bad value

collect2: ld returned 1 exit status
```

Too much of a coincidence to be unconnected?  I'll try rebuilding the current version and see what that does.

Would kernel config affect this? I have CONFIG_STACKOVERFLOW unset, I wonder if it should be set. Or maybe linux-headers is involved?

----------

## Hu

 *Havin_it wrote:*   

> Would kernel config affect this? I have CONFIG_STACKOVERFLOW unset, I wonder if it should be set. Or maybe linux-headers is involved?

 Are you sure that is the correct name?  I do not see that name in a vanilla Kconfig.  The kernel option CC_STACKPROTECTOR uses the same compiler feature, but is independent of setting -fstack-protector on user code.  You can use them together or separately.  For best protection, use both.  However, changing CC_STACKPROTECTOR is unlikely to help with your Apache problem.

----------

## Havin_it

Sorry, that should have been CONFIG_DEBUG_STACKOVERFLOW. And no, it hasn't helped  :Sad:  it seemed a long shot anyway.

Latest update is that I can't rebuild my current glibc-2.14.1-r3 either, it is failing with the same error as above. I feel this has to be significant, but what might affect the building of glibc? Not much, I'd have thought. Maybe I need to rebuild the whole toolchain?

Also maybe I should try building without ccache, distcc (using crossdev on an amd64 box as peer) to see if that helps. I'd just emptied ccache before the most recent apache rebuild though, so I'm surprised if that's an issue.

----------

## cach0rr0

 *Havin_it wrote:*   

> 
> 
> Also maybe I should try building without ccache, distcc 

 

yes yes and yes. It is possible to build toolchain components with ccache/distcc. It is however not a good idea to build toolchain components with ccache/dstcc.

----------

## Havin_it

Och, I know, I've heard the warnings, but merging gcc on a 1st-gen Atom is no picnic  :Sad: 

BTW here's my CFLAGS line, I wonder if it contains anything pertinent here. It's so verbose because I used a one-liner I picked up here a while ago that supposedly translates -march=native to all the flags it enables (needed this for distcc to work). My own added flags are in the second declaration (ya I know most are redundant, but I'm a paranoid ricer...)

```
CFLAGS="-D_FORTIFY_SOURCE=2 -march=atom -msahf -mmovbe --param l1-cache-size=24 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=atom"

CFLAGS="${CFLAGS} -O2 -fomit-frame-pointer -pipe -mmmx -msse -msse2 -mssse3"
```

The -D_FORTIFY_SOURCE=2 item occurs that it might be pertinent...?

----------

## Hu

 *Havin_it wrote:*   

> Och, I know, I've heard the warnings, but merging gcc on a 1st-gen Atom is no picnic 

 If you have the drive space to spare, you could install a minimal clone of the Atom on a beefier system, build gcc there with FEATURES=buildpkg, then have the Atom install the prebuilt gcc.  You can do this for any package, provided that you have a build host capable of building something that the Atom can run.

 *Havin_it wrote:*   

> (ya I know most are redundant, but I'm a paranoid ricer...)

 Although likely true, that is not the best statement to make when reporting a problem that may well be caused by overaggressive optimization flags.  :Smile: 

 *Havin_it wrote:*   

> 
> 
> ```
> CFLAGS="-D_FORTIFY_SOURCE=2 -march=atom -msahf -mmovbe --param l1-cache-size=24 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=atom"
> 
> ...

 It should not be.  sys-libs/glibc goes out of its way to prevent _FORTIFY_SOURCE from being used.  When last I checked, they undefine it three times in a row to be really sure.  :Wink:   Most of sys-libs/glibc builds fine with fortification, but there are a few functions that do not, so disabling it for the entire package is clearly the best option.  :Rolling Eyes: 

----------

