Program received signal SIGILL, Illegal instruction. 0x46096268 in ?? () from /lib/libcrypto.so.1.0.

在调试APP时,遇到了SIGILL错误,即非法指令信号。这通常发生在OpenSSL初始化期间,由于OpenSSL为了适配处理器而尝试某些可能导致异常的指令。文章提供了两种解决方案:一是设置环境变量绕过查询,二是配置gdb在遇到SIGILL时不暂停。作者选择了后者并在.gdbinit中添加handleSIGILLnostop,成功进行了调试。
摘要由CSDN通过智能技术生成

1 问题描述

开发APP进行GBD调试,程序自己运行时无问题,调试则遇到
GDB:Program received signal SIGILL, Illegal instruction. 0x46096268 in ?? () from /lib/libcrypto.so.1.0.

(gdb) start
Temporary breakpoint 1 at 0x183e0: file
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
warning: Unable to find libthread_db matching inferior’s thread library, thread debugging will not be available.

Program received signal SIGILL, Illegal instruction.
0x46096268 in ?? () from /lib/libcrypto.so.1.0.0

2 SIGILL介绍

进程在运行过程中会收到SIGILL信号,此类错误是由操作系统发送给进程的。

SIGILL是某个进程中的某一句不能被CPU识别指令,这些指令可能是一些形式错误、未知或者特权指令。

详细见:https://www.cnblogs.com/arnoldlu/p/10815908.html

3 解决办法

 (gdb) handle SIGILL nostop noprint

4根本原因

When debugging I observe SIGILL during OpenSSL initialization?

OpenSSL adapts to processor it executes on and for this reason has to
query its capabilities. Unfortunately on some processors the only way
to achieve this for non-privileged code is to attempt instructions
that can cause Illegal Instruction exceptions. The initialization
procedure is coded to handle these exceptions to manipulate
corresponding bits in capabilities vector. This normally appears
transparent, except when you execute it under debugger, which stops
prior delivering signal to handler. Simply resuming execution does the
trick, but when debugging a lot it might feel counterproductive. Two
options. Either set explicit capability environment variable in order
to bypass the capability query (see corresponding crypto/*cap.c for
details). Or configure debugger not to stop upon SIGILL exception,
e.g. in gdb case add ‘handle SIGILL nostop’ to your .gdbinit.

官方原文地址:https://www.openssl.org/docs/faq.html#PROG17
OpenSSL为了适应处理器,因此必须查询它的能力。不幸的是,在某些处理器上,实现非特权代码的唯一方法是尝试可能导致非法指令异常的指令。初始化过程被编码来处理这些异常。这通常是透明的,除非你在调试器下执行它,它会在向处理程序传递信号之前停止。简单地恢复执行就可以了,但是当大量调试时可能会适得其反。两个选择。
1、设置显式的能力环境变量以绕过能力查询(参见相应的crypto/*cap.c了解详细信息)。
2、或者配置调试器在SIGILL异常时不停止,例如在gdb的情况下,在.gdbinit中添加’ handle SIGILL nostop '。

这里我使用第二种,成功进行调试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值