Commit a99ba6df authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use -fPIC instead of -fPIE that causes SEGV on gcc 5.

In my latest Ubuntu's gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2), userhosts causes SEGV. You can reproduce the issue with current SlapOS gcc-5.3.0 as well.

```
$ gdb --args ./userhosts ls
(gdb) run
Starting program: /srv/slapgrid/slappart0/srv/runner/software/d65309081a071d10fa34fce376e82fd7/parts/userhosts/userhosts ls
process 11758 is executing new program: /bin/ls
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
COPYING  debian  Makefile  README  userhosts  userhosts.c
 
Program received signal SIGSEGV, Segmentation fault.
__fpending (fp=0x0) at __fpending.c:23
23      __fpending.c: No such file or directory.
(gdb) bt
#0  __fpending (fp=0x0) at __fpending.c:23
#1  0x0000000000411e4c in ?? ()
#2  0x000000000040a075 in ?? ()
#3  0x00007ffff7418d32 in __run_exit_handlers (status=0, listp=0x7ffff77a3698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#4  0x00007ffff7418d85 in __GI_exit (status=<optimised out>) at exit.c:104
#5  0x0000000000404067 in ?? ()
#6  0x00007ffff73ffa40 in __libc_start_main (main=0x4028a0, argc=1, argv=0x7fffffffeb48, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffeb38) at libc-start.c:289
#7  0x0000000000404899 in ?? ()
(gdb) bt full
#0  __fpending (fp=0x0) at __fpending.c:23
No locals.
#1  0x0000000000411e4c in ?? ()
No symbol table info available.
#2  0x000000000040a075 in ?? ()
No symbol table info available.
#3  0x00007ffff7418d32 in __run_exit_handlers (status=0, listp=0x7ffff77a3698 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
        atfct = <optimised out>
        onfct = <optimised out>
        cxafct = <optimised out>
        f = <optimised out>
#4  0x00007ffff7418d85 in __GI_exit (status=<optimised out>) at exit.c:104
No locals.
#5  0x0000000000404067 in ?? ()
No symbol table info available.
#6  0x00007ffff73ffa40 in __libc_start_main (main=0x4028a0, argc=1, argv=0x7fffffffeb48, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffeb38) at libc-start.c:289
        result = <optimised out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -8764054844010181565, 4212848, 140737488350016, 0, 0, 8764055384653253699, 8764071327084268611}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x412420, 0x7fffffffeb48}, data = {prev = 0x0, cleanup = 0x0,
              canceltype = 4269088}}}
        not_first_call = <optimised out>
#7  0x0000000000404899 in ?? ()
No symbol table info available.

```

Using '-fPIC' instead of '-fPIE' solved the issue. I confirm that it works with this change on gcc-4.9 as well.

/cc @vpelletier, @jm 

/reviewed-on !1
parent d3080ad4
CFLAGS ?= -O2 -s
CFLAGS += -Wall -fPIE -pie
CFLAGS += -Wall -fPIC -pie
LDLIBS = -ldl
PREFIX = /usr/local
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment