You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe this is normal (I've seen this when debugging xbmc for a couple of years).
I suspect the code is deliberately executing the illegal instruction with a signal handler enabled (e.g. to determine whether optional instructions are supported).
See: http://stackoverflow.com/questions/15071625/gdb-ddd-program-received-signal-sigill
I actually checked for this too, but even when I use handle SIGILL pass nostop noprint, the program dies in gdb with the same error. I suppose I should have noted that in the first post.
This has been hair-pullingly frustrating to figure out on my own for the past two weeks, so I threw in the towel today and submitted it as an issue. 😁
Unfortunately the kernel change was the 3.12 to 3.18 (so literally tens of thousands of commits...)
Can you determine the instruction generating the exception (e.g. with "disas")
Short term, I'd suggest just doing a custom patch. I have not yet had a chance to file a bug against Debian (things kind of blew up at work shortly after I posted that comment), and it may take a while to convince them to include it, if they decide to include it at all.
Shiftplusone just pointed me at this. So far I have failed to reproduce it. Specificafically I have failed to get the compiler to spit out a "UNIX - GNU" binary.
@plugwash Just gave this a go myself. Compiled a kernel with CONFIG_OABI_COMPAT=n and a version of GDB with the patch applied. Using zdoom linked earlier as an example, without installing that version of GDB:
pi@raspberrypi:~/zdoom/build $ gdb zdoom
GNU gdb (Raspbian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 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 "arm-linux-gnueabihf".
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 zdoom...done.
(gdb) run
Starting program: /home/pi/zdoom/build/zdoom
Program received signal SIGILL, Illegal instruction.
_dl_debug_initialize (ldbase=1685382482, ns=195904) at dl-debug.c:47
47 dl-debug.c: No such file or directory.
(gdb)
Installing the patched version of GDB and trying again...
pi@raspberrypi:~/zdoom/build $ sudo dpkg -i ../../dev/gdb_7.7.1+dfsg-5+rpi1_armhf.deb
(Reading database ... 70074 files and directories currently installed.)
Preparing to unpack .../gdb_7.7.1+dfsg-5+rpi1_armhf.deb ...
Unpacking gdb (7.7.1+dfsg-5+rpi1) over (7.7.1+dfsg-5) ...
Setting up gdb (7.7.1+dfsg-5+rpi1) ...
Processing triggers for man-db (2.7.0.2-5) ...
pi@raspberrypi:~/zdoom/build $ gdb zdoom
GNU gdb (Raspbian 7.7.1+dfsg-5+rpi1) 7.7.1
Copyright (C) 2014 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 "arm-linux-gnueabihf".
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 zdoom...done.
(gdb) run
Starting program: /home/pi/zdoom/build/zdoom
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
ZDoom 2.9pre-1230-gbf5f10a - 2016-09-02 10:48:38 +0200 - SDL version
Compiled on Sep 2 2016
M_LoadDefaults: Load system defaults.
Cannot find a game IWAD (doom.wad, doom2.wad, heretic.wad, etc.).
Did you install ZDoom properly? You can do either of the following:
1. Place one or more of these wads in ~/.config/zdoom/.
2. Edit your ~/.config/zdoom/zdoom.ini and add the directories of your
iwads to the list beneath [IWADSearch.Directories]
[Inferior 1 (process 13140) exited with code 0377]
(gdb)
I'm developing on the Allwinner A20 & A33 CPUs, which contains ARM cores.
I've first noticed the segfault during remote debugging, using gdbserver,
from my host PC to the target. Debugging the the application directly on
the target did not cause this problem. Performing the remote debugging from
a 32-bit host to the 32-bit target made no difference. That seemed to
eliminate the possibility of a 64/32 bit compatibility issue.
Program: main.c
#include <stdio.h>
int main (void)
{
printf("Hallo world!\n");
return 0;
}
Compile on host PC:
$ arm-linux-gnueabihf-gcc -g main.c -o main_32
File signature:
$ file main_32
main_32: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked,
interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32,
BuildID[sha1]=cc1a4a1ff17da63f9f8362c84dffe54ee7fff4ff, not stripped
Remote target:
The executable (main_32) needs to be copied to the remote target
$ gdbserver :5555 main_32
Process main_32 created; pid = 904
Listening on port 5555
Remote debugging from host 192.168.7.2
Host PC:
$ arm-linux-gnueabihf-gdb ./main_32
(gdb) target remote 192.168.7.1:5555
Remote debugging using 192.168.7.1:5555
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally
instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/ld-linux-armhf.so.3...Reading /lib/ld-2.23.so from remote target...
Reading /lib/.debug/ld-2.23.so from remote target...
(no debugging symbols found)...done.
0xb6fd7a40 in ?? () from target:/lib/ld-linux-armhf.so.3
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0xb6fd9822 in ?? () from target:/lib/ld-linux-armhf.so.3
To try and figure out where the segfault occurred the debug symbols need to be loaded.
The gdb command 'set debug-file-directory' can be used to accomplish this. It seems that this command
is only relative to the host PC filesystem and not according to the remote target file system.
With 'set sysroot' the debugger can also be instructed to load all data locally instead of transferring it
runtime over the network.
Make sure the debug symbols are on the remote file system:
apt-get install libc6-dbg
Copy the full contents of the SD card residing on the Allwinner A20 rootfs to a local directory on
the host PC: /opt/gnueabihf_rootfs
Illustrating the solution
Remote target:
$ gdbserver :5555 main_32
Process main_32 created; pid = 912
Listening on port 5555
Remote debugging from host 192.168.7.2
Hallo world!
Child exited with status 0
Host PC:
$ arm-linux-gnueabihf-gdb ./main_32
(gdb) set debug-file-directory /opt/gnueabihf_rootfs/usr/lib/debug
(gdb) set sysroot /opt/gnueabihf_rootfs
(gdb) target remote 192.168.7.1:5555
Remote debugging using 192.168.7.1:5555
Reading symbols from /opt/gnueabihf_rootfs/lib/ld-linux-armhf.so.3...done.
Reading symbols from /opt/gnueabihf_rootfs/usr/lib/debug/lib/arm-linux-gnueabihf/ld-2.23.so...done.
0xb6fd7a40 in _start ()
(gdb) continue
Continuing.
Cannot parse expression `.L966 4@r4'.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
Even though there is a warning regarding "Probes-based dynamic linker interface failed", the program
keeps on running correctly. The thread describing the GDB patch about the linker interface can be
read at: https://sourceware.org/ml/gdb-patches/2015-08/msg00629.html
It appears the work around was introduced around August 2015, but if you do not specify the path to
the debug symbols, the debugger still segfaults.
The 'set debug-file-directory' and 'set sysroot' can be added to the .gdbinit file to be applied
automatically when you start a remote debug session.
Note: Activating the kernel option: CONFIG_OABI_COMPAT did not fix the problem on the Allwinner A20 or A33.
Hi,
I'm still facing this problem can anybody confirm what is the cause of the problem? kernel itself? I'm trying to cross-compile my app with linaro toolchain and using its debugger arm-linux-gnueabihf-gdb to debug remotely.
Activity
popcornmix commentedon Jan 23, 2015
I believe this is normal (I've seen this when debugging xbmc for a couple of years).
I suspect the code is deliberately executing the illegal instruction with a signal handler enabled (e.g. to determine whether optional instructions are supported).
See:
http://stackoverflow.com/questions/15071625/gdb-ddd-program-received-signal-sigill
sneakernets commentedon Jan 23, 2015
I actually checked for this too, but even when I use
handle SIGILL pass nostop noprint, the program dies ingdbwith the same error. I suppose I should have noted that in the first post.This has been hair-pullingly frustrating to figure out on my own for the past two weeks, so I threw in the towel today and submitted it as an issue. 😁
nbrachet commentedon Jan 30, 2015
I have experienced this issue too after a recent upgrade -- sadly I don't remember which one.
I traced this SIGILL down to a static initialization in my code. Still frustrating issue.
popcornmix commentedon Jan 31, 2015
@nbrachet A firmware/kernel upgrade, or other packages?
nbrachet commentedon Jan 31, 2015
@popcornmix I'm afraid both.
nbrachet commentedon Jan 31, 2015
If that helps the problem occurs whether I build with g++-4.6 or g++-4.8.
popcornmix commentedon Jan 31, 2015
If it was a firmware/kernel update that caused it, then downgrading should fix it. You can revert to an older version:
http://raspberrypi.stackexchange.com/questions/15917/restore-kernel-version/15919#15919
sneakernets commentedon Feb 2, 2015
If it helps, this started to be an issue around mid-december 2014.
nbrachet commentedon Feb 6, 2015
I've tracked down the firmware version in which this bug appeared: cad071a, and it present up to the latest 93cb9a4
sneakernets commentedon Feb 6, 2015
Yeah, it looks like 3.18 firmware update still has some rough edges. Thanks for letting me know!
popcornmix commentedon Feb 7, 2015
Unfortunately the kernel change was the 3.12 to 3.18 (so literally tens of thousands of commits...)
Can you determine the instruction generating the exception (e.g. with "disas")
popcornmix commentedon Feb 7, 2015
One thing I've notice is 3.18 kernel reports:
Features : half thumb fastmult vfp edsp java tls
The older kernel reports:
Features : swp half thumb fastmult vfp edsp java tls
The (deprecated) swp feature was removed here:
58171bf
So if the instruction is a swp instruction this may be relevant.
nbrachet commentedon Feb 9, 2015
Here's the disas:
Expanding on this...:
popcornmix commentedon Feb 9, 2015
Can you post the binary that does this? (e.g. to dropbox or google drive)
nbrachet commentedon Feb 9, 2015
https://dl.dropboxusercontent.com/u/1020551/rtpraspivid
Offending code is:
When pid is defined as a static (as it is in the executable I posted to dropbox) the executable SIGILL in gdb.
Note that the same problem happens if I replace the call to getpid() with a call to:
But it does not happen if I replace the call to getpid() with a constant:
It does feel like a stack corruption... Could gdb be corrupting the stack somehow?
35 remaining items
popcornmix commentedon Aug 31, 2016
@khuey Thanks for checking. Hopefully it will make it to stable at some point.
XECDesign commentedon Aug 31, 2016
@popcornmix debian is not likely to bump gdb version in stable. Any reason not to patch 7.7.1 in our releases?
popcornmix commentedon Sep 1, 2016
@XECDesign yes that is an option.
@Ferroin mentioned requesting this patch be applied to debian as it seems like a bug fix:
See: raspberrypi/firmware#652
If that happens we should get the patched version by default, but if not we can add a custom patch.
Ferroin commentedon Sep 1, 2016
Short term, I'd suggest just doing a custom patch. I have not yet had a chance to file a bug against Debian (things kind of blew up at work shortly after I posted that comment), and it may take a while to convince them to include it, if they decide to include it at all.
plugwash commentedon Sep 1, 2016
Shiftplusone just pointed me at this. So far I have failed to reproduce it. Specificafically I have failed to get the compiler to spit out a "UNIX - GNU" binary.
XECDesign commentedon Sep 2, 2016
@plugwash Just gave this a go myself. Compiled a kernel with CONFIG_OABI_COMPAT=n and a version of GDB with the patch applied. Using zdoom linked earlier as an example, without installing that version of GDB:
Installing the patched version of GDB and trying again...
plugwash commentedon Sep 3, 2016
did you compile that zdoom binary yourself? if so with what compiler on what version of raspbian?
XECDesign commentedon Sep 3, 2016
Yes, straight forward compile using the toolchain from raspbian jessie.
frixhub commentedon Nov 5, 2016
Good day,
I'm developing on the Allwinner A20 & A33 CPUs, which contains ARM cores.
I've first noticed the segfault during remote debugging, using gdbserver,
from my host PC to the target. Debugging the the application directly on
the target did not cause this problem. Performing the remote debugging from
a 32-bit host to the 32-bit target made no difference. That seemed to
eliminate the possibility of a 64/32 bit compatibility issue.
My setup:
Host PC:
Kubuntu 16.04 64-bit
Toolchain: gcc-linaro-6.1.1-2016.08
: gdb version (Linaro_GDB-2016.08) 7.11.1.20160801-git
Obtained from: https://releases.linaro.org/components/toolchain/binaries
Target:
Ubuntu 16.04 ARMHF
: GDB version: (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Illustrating the problem
Program: main.c
#include <stdio.h>
int main (void)
{
printf("Hallo world!\n");
return 0;
}
Compile on host PC:
$ arm-linux-gnueabihf-gcc -g main.c -o main_32
File signature:
$ file main_32
main_32: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked,
interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32,
BuildID[sha1]=cc1a4a1ff17da63f9f8362c84dffe54ee7fff4ff, not stripped
Remote target:
The executable (main_32) needs to be copied to the remote target
$ gdbserver :5555 main_32
Process main_32 created; pid = 904
Listening on port 5555
Remote debugging from host 192.168.7.2
Host PC:
$ arm-linux-gnueabihf-gdb ./main_32
(gdb) target remote 192.168.7.1:5555
Remote debugging using 192.168.7.1:5555
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally
instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/ld-linux-armhf.so.3...Reading /lib/ld-2.23.so from remote target...
Reading /lib/.debug/ld-2.23.so from remote target...
(no debugging symbols found)...done.
0xb6fd7a40 in ?? () from target:/lib/ld-linux-armhf.so.3
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0xb6fd9822 in ?? () from target:/lib/ld-linux-armhf.so.3
To try and figure out where the segfault occurred the debug symbols need to be loaded.
The gdb command 'set debug-file-directory' can be used to accomplish this. It seems that this command
is only relative to the host PC filesystem and not according to the remote target file system.
With 'set sysroot' the debugger can also be instructed to load all data locally instead of transferring it
runtime over the network.
Make sure the debug symbols are on the remote file system:
apt-get install libc6-dbg
Copy the full contents of the SD card residing on the Allwinner A20 rootfs to a local directory on
the host PC: /opt/gnueabihf_rootfs
Illustrating the solution
Remote target:
$ gdbserver :5555 main_32
Process main_32 created; pid = 912
Listening on port 5555
Remote debugging from host 192.168.7.2
Hallo world!
Child exited with status 0
Host PC:
$ arm-linux-gnueabihf-gdb ./main_32
(gdb) set debug-file-directory /opt/gnueabihf_rootfs/usr/lib/debug
(gdb) set sysroot /opt/gnueabihf_rootfs
(gdb) target remote 192.168.7.1:5555
Remote debugging using 192.168.7.1:5555
Reading symbols from /opt/gnueabihf_rootfs/lib/ld-linux-armhf.so.3...done.
Reading symbols from /opt/gnueabihf_rootfs/usr/lib/debug/lib/arm-linux-gnueabihf/ld-2.23.so...done.
0xb6fd7a40 in _start ()
(gdb) continue
Continuing.
Cannot parse expression `.L966 4@r4'.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
Even though there is a warning regarding "Probes-based dynamic linker interface failed", the program
keeps on running correctly. The thread describing the GDB patch about the linker interface can be
read at: https://sourceware.org/ml/gdb-patches/2015-08/msg00629.html
It appears the work around was introduced around August 2015, but if you do not specify the path to
the debug symbols, the debugger still segfaults.
The 'set debug-file-directory' and 'set sysroot' can be added to the .gdbinit file to be applied
automatically when you start a remote debug session.
Note: Activating the kernel option: CONFIG_OABI_COMPAT did not fix the problem on the Allwinner A20 or A33.
Regards,
Frikkie Thirion
kernel: config: Add OABI_COMPAT to fix gdb illegal instructions
gdb: Do arm_abi detection for ELFOSABI_GNU binaries
masoudr commentedon Sep 1, 2018
Hi,
I'm still facing this problem can anybody confirm what is the cause of the problem? kernel itself? I'm trying to cross-compile my app with
linaro toolchainand using its debuggerarm-linux-gnueabihf-gdbto debug remotely.Merge pull request raspberrypi#766 from sulix/rust-uml
staging: vme_user: Fix checkpatch warnings in vme_tsi148.c
selftests/bpf: Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate