gdb/ddd 程序收到信号 SIGILL [英] gdb/ddd Program received signal SIGILL

查看:36
本文介绍了gdb/ddd 程序收到信号 SIGILL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Linux 中使用 c++ 编写了一个非常简单的程序,它使用 cURL 库通过 http(基本上开发了一个 http 客户端请求)从某个网站下载图像.http://curl.haxx.se/libcurl/c/allfuncs.html

#define CURL_STATICLIB#include #include #include </usr/include/curl/curl.h>#include </usr/include/curl/stdcheaders.h>#include size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {size_t 写入 = fwrite(ptr, 大小, nmemb, 流);回写;}int main(void) {卷曲 *卷曲;文件 *fp;CURLcode res;char *url = "http://www.example.com/test_img.png";char outfilename[FILENAME_MAX] = "/home/c++_proj/output/web_req_img.png";curl = curl_easy_init();如果(卷曲){fp = fopen(outfilename,"wb");curl_easy_setopt(卷曲,CURLOPT_URL,网址);curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);res = curl_easy_perform(curl);/* 总是清理 */curl_easy_cleanup(卷曲);fclose(fp);}返回0;}

我验证了代码,它工作正常.我可以看到图像已下载并且我可以查看图像(没有错误或警告).由于我计划扩展我的代码,我尝试安装 ddd,并使用调试器,但调试器不起作用,并且当我尝试使用 ddd 运行我的程序时,我的程序退出并出现某种信号错误.

这是错误:

(启用使用 libthread_db 的线程调试)使用主机 libthread_db 库/lib/arm-linux-gnueadihf/libthread_db.so.1"程序收到信号SIGILL,非法指令.0xb6a5c4C0 在 ??() 来自/usr/lib/arm-linux-gnueadbihf/libcrypto.so.1.0.0

起初我以为我没有正确安装 ddd,所以我又回到了 gdb,但是当我运行程序时,我得到了完全相同的错误.(而且我相信我使用的是最新版本的 gdb 和 ddd)

然后我尝试在另一个不涉及 cURL 库的简单程序上使用 ddd,并且效果很好!!!

有谁知道为什么会这样,解决方法是什么?在 ddd 运行时,我是否需要以某种方式指向 cURL 库?但是,在过去,我不记得用不同的库来做这件事!也许这是 ddd 不喜欢的卷曲?但是程序在没有调试器的情况下运行良好!我将不胜感激.

解决方案

我猜它可能是某些指令集检测代码的一部分.让程序继续运行,看看它是否自己处理信号(因为它在 gdb 之外运行,它可能会).或者,您可以在运行程序之前告诉 gdb 不要用 SIGILL 来打扰您:handle SIGILL pass nostop noprint.

如果程序死了,这只是一个问题,从你的问题中不清楚.

I wrote a very simple program in Linux using c++, which downloads images from some website over http (basically developed a http client request), using cURL libraries. http://curl.haxx.se/libcurl/c/allfuncs.html

#define CURL_STATICLIB
#include <stdio.h>
#include <stdlib.h>
#include </usr/include/curl/curl.h>
#include </usr/include/curl/stdcheaders.h>
#include </usr/include/curl/easy.h>

size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    size_t written = fwrite(ptr, size, nmemb, stream);
    return written;
}

int main(void) {
    CURL *curl;
    FILE *fp;
    CURLcode res;

    char *url = "http://www.example.com/test_img.png"; 
    char outfilename[FILENAME_MAX] = "/home/c++_proj/output/web_req_img.png";
    curl = curl_easy_init();
    if (curl) {
        fp = fopen(outfilename,"wb");
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        res = curl_easy_perform(curl);
        /* always cleanup */
        curl_easy_cleanup(curl);
        fclose(fp);
    }
    return 0;
}

I verified the code, and it works fine. I can see the image is downloaded and that I can view the image (with no errors or warnings). Since I plan on expanding my code, I tried to install ddd, and use the debugger, but the debugger doesn't work, and my program exits with some sort of Signal errors, when I try to run my program with ddd.

This is the error:

 (Threadd debugging using libthread_db enabled)
 Using host libthread_db library "/lib/arm-linux-gnueadihf/libthread_db.so.1"

 Program received signal SIGILL, illegal instruction.
 0xb6a5c4C0 in ?? () from /usr/lib/arm-linux-gnueadbihf/libcrypto.so.1.0.0

First I thought that I didn't properly install ddd, so I went back to gdb, but I get the exact same errors, when I run the program. (And I believe that I am using the latest version of gdb and ddd)

Then I tried to use ddd on another simple program, that doesn't involve cURL library, and it worked fine !!!

Does anyone know why this is the case, and what is the solution? Do I somehow need to point to cURL libraries while ddd is running? But, in the past, I don't recall doing this with different set of libraries! Maybe it is something abuot the cURL that ddd doesn't like? But the program runs fine itself without the debugger! I would appreciate some help.

解决方案

I am guessing it may be part of some instruction set detection code. Just let the program continue and see if it handles the signal by itself (since it runs outside of gdb, it probably does). Alternatively, you can tell gdb to not bother you with SIGILL at all before you run the program: handle SIGILL pass nostop noprint.

It's only a problem if the program dies, which was not clear from your question.

这篇关于gdb/ddd 程序收到信号 SIGILL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆