#20 mtcp_maybebpt.c:78: undefined reference to `__stack_chk_fail

open
Kapil Arya
MTCP (1)
2012-10-09
2012-10-09
Orion Poplawski
No

Trying to build 1.2.6 as a Fedora package, get:

gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -O0 -g -DUSE_PROC_MAPS -DDMTCP_VERSION=\"1.2.6\" -fPIC -DPIC -fno-stack-protector -fstack-protector -c -o mtcp_maybebpt.o mtcp_maybebpt.c
In file included from /usr/include/fcntl.h:27:0,
from mtcp_maybebpt.c:30:
/usr/include/features.h:314:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
In file included from mtcp_internal.h:141:0,
from mtcp_maybebpt.c:37:
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -O0 -g -DUSE_PROC_MAPS -DDMTCP_VERSION=\"1.2.6\" -fPIC -DPIC -fno-stack-protector -static -nodefaultlibs \ -o mtcp_restart mtcp_restart.c mtcp_maybebpt.o \ mtcp_printf.o mtcp_util.o mtcp_safemmap.o \ mtcp_state.o mtcp_safe_open.o \ mtcp_check_vdso.o mtcp_fastckpt.o
In file included from /usr/include/unistd.h:26:0,
from mtcp_restart.c:38:
/usr/include/features.h:314:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
In file included from mtcp_internal.h:141:0,
from mtcp_restart.c:50:
mtcp_sys.h:322:1: warning: multi-line comment [-Wcomment]
mtcp_maybebpt.o: In function `mtcp_maybebpt':
/export/home/orion/redhat/dmtcp-1.2.6/dmtcp-1.2.6/mtcp/mtcp_maybebpt.c:78: undefined reference to `__stack_chk_fail_local'
/usr/bin/ld: mtcp_restart: hidden symbol `__stack_chk_fail_local' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

I think compiling one with -fstack-protector and the other without isn't going to work. Dropping it on mtcp_maybebpt.c works. Not sure why it appears to work on debian. Perhaps interaction with _FORTIFY_SOURCE?

Discussion

  • Remove -fstack-protector from mtcp_maybebpt.c

     
  • Kapil Arya
    Kapil Arya
    2012-10-09

    • labels: --> MTCP
    • assigned_to: nobody --> karya
     
  • Kapil Arya
    Kapil Arya
    2012-10-09

    Thanks for reporting this issue Orion. I will look into it in a couple of hours and will write back with the fix.