ssrg-vt / popcorn-compiler

Popcorn Linux compiler toolchain for heterogeneous-ISA execution
42 stars 22 forks source link

Segmentation fault during homogeneous execution on aarch64 #17

Closed acarno closed 6 years ago

acarno commented 6 years ago

Running any of the NPB Serial applications on aarch64 without migrating (i.e., homogeneously) fails before reaching main.

Example:

dmesg output when running EP_A_aarch64 (gzipped binary attached):

[146742.464428] CPU: 2 PID: 3106 Comm: EP_A_aarch64 Not tainted 4.4.55+ #1
[146742.464429] Hardware name: AppliedMicro (R)     AppliedMicro X-C2 (TM) EV-883408-X2-MXB-1  /AppliedMicro X-C2   , BIOS 5.11 08/27/2016
[146742.464431] task: ffffffc7da06a280 ti: ffffffc7d85a4000 task.ti: ffffffc7d85a4000
[146742.464434] PC is at 0x50fd54
[146742.464435] LR is at 0x50fcfc
[146742.464437] pc : [<000000000050fd54>] lr : [<000000000050fcfc>] pstate: 60000000
[146742.464438] sp : 0000007fffffecb0
[146742.464439] x29: 0000007fffffecb0 x28: 0000000000000000 
[146742.464441] x27: 0000007fffffecd0 x26: 0000000000000000 
[146742.464444] x25: 0000000000000000 x24: 0000000000000000 
[146742.464446] x23: 0000000000000001 x22: 0000008000000000 
[146742.464448] x21: 0000007fff800000 x20: 0000000000b02040 
[146742.464450] x19: 0000000000b02020 x18: 0000007fffffcaf0 
[146742.464452] x17: 000000005d6b6361 x16: 0000007fffffe990 
[146742.464455] x15: 0000007fffffe9b0 x14: 0000000000000006 
[146742.464457] x13: 0000000000000000 x12: 0000000000000000 
[146742.464459] x11: 8080808000000000 x10: 000000000000004c 
[146742.464461] x9 : 000000000000004f x8 : 000000000000004c 
[146742.464463] x7 : 0000007ffffff110 x6 : 0000007ffffff100 
[146742.464465] x5 : 0000007ffffff118 x4 : 0000007ffffff108 
[146742.464467] x3 : 0000007fffffece0 x2 : 0000000000000014 
[146742.464469] x1 : 5f706f7000746e69 x0 : 0000000000000001 

GDB output:

[anthony@xgene2 09:42 ~]$ gdb ./EP_A_aarch64
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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 "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./EP_A_aarch64...done.
(gdb) run
Starting program: /home/anthony/EP_A_aarch64

Program received signal SIGSEGV, Segmentation fault.
0x000000000050fd54 in elf_version ()
(gdb) bt
#0  0x000000000050fd54 in elf_version ()
#1  0x0000000000509c18 in __st_userspace_ctor () at src/userspace.c:103
#2  0x0000000000502640 in libc_start_init () at src/env/__libc_start_main.c:61
#3  0x0000000000502690 in __libc_start_main (main=0x501210 <main>, argc=1, argv=0x7ffffff1d8)
    at src/env/__libc_start_main.c:75
#4  0x0000000000502434 in _start_c (p=<optimized out>) at crt/crt1.c:17
#5  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

ep_A_example.tar.gz

acarno commented 6 years ago

Issue appears to have stemmed from libelf -- for some reason, the library was compiling with position-independent code. Adding -fno-pic -fno-PIC to the CFLAGS argument when compiling the library solved the problem.

For posterity, @rlyerly had trouble duplicating the error -- his development machine uses GCC 5.4.0, while mine uses GCC 6.3.0. Perhaps that has something to do with it? Closing as resolved.

acarno commented 6 years ago

Fixed (well, avoided) in commit 17ab1f51ef29772add42ff9d05b2568758d9b0fb