标签: coredump

包含ada dll的崩溃C++应用程序不会生成核心转储

如何获取包含加载的ada共享库的C++应用程序,以便在崩溃时生成核心转储?

我有一个加载ada共享库的C++应用程序,在ada代码中我遇到堆栈溢出错误导致程序终止以及控制台输出:

raised STORAGE ERROR
Run Code Online (Sandbox Code Playgroud)

即使您在启动应用程序之前发出了"ulimit -c unlimited",也不会生成核心转储文件.

如果我向 应用程序发送kill SIGSEGV,也会发生同样的事情.

将kill SIGSEGV发送到另一个不使用ada dll的应用程序会按照我希望的方式生成核心转储文件.

在这里找到一些信息:http://objectmix.com/ada/301203-gnat-fstack-check-does-work.html

更新!正如Adrien所提到的,没有矛盾,-s设置堆栈限制,而-c设置核心文件限制.

问题仍然存在.我在构建ada库时检查了标志,并且未设置fstack-check标志,因此它应该生成核心转储.

我还没试过,看起来有些奇怪.它提到-fstack-check编译器选项+设置GNAT_STACK_LIMIT变量但同时引用ulimit命令似乎是一个矛盾,设置"ulimit -c"是我知道生成核心转储的唯一方法在崩溃时,如果这与fstack-check选项有关,那么我们有一个捕获22.

c++ coredump exception ada

0
推荐指数
1
解决办法
1432
查看次数

这种分段错误背后的原因

这是我计算数字的反正弦的函数.它导致0.51-0.8之间的值的分段错误:

double my_asin(double x)
{
    double sum = x;
    if(x < -1.0 || x > 1.0)
    {
        /* error handling */
    }
    else if(x < -0.5)
    {
        sum = -0.5*PI + my_asin(my_sqrt(1-my_pow(x,2))); // SIG_SEGV
        return sum;
    }
    else if(x > 0.5)
    {
        sum = 0.5*PI - my_asin(my_sqrt(1-my_pow(x,2))); // SIG_SEGV
        return sum;
    }

    /* variable initialization */

    while(my_abs(b - a) > EPSILON2)
    {
        /*code*/
    }
    /* return result */
}
Run Code Online (Sandbox Code Playgroud)

GDB和valgrind都告诉我错误发生在函数my_pow中,它完全按照您的想法执行,因此无需在此处发布.你能看一眼并指出我正确的方向吗?非常感谢.

c coredump trigonometry segmentation-fault

0
推荐指数
1
解决办法
81
查看次数

***堆栈粉碎检测***中止(核心倾倒)

我正在尝试调试一个给出错误的程序:Abort(core dumped).Valgrind检测到堆栈粉碎并给出一个LEAK SUMMARY,其中1个块仍然可以访问.它向函数downloadAndOpen的第12行发出信号,在那里我有一个我认为在main结束时关闭的fopen,但它似乎不是.我很感激这个bug的帮助.valgrind输出是:

*** stack smashing detected ***: ./mtg terminated
==9594== 
==9594== HEAP SUMMARY:
==9594==     in use at exit: 352 bytes in 1 blocks
==9594==   total heap usage: 1 allocs, 0 frees, 352 bytes allocated
==9594== 
==9594== 352 bytes in 1 blocks are still reachable in loss record 1 of 1
==9594==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9594==    by 0x40BE62B: __fopen_internal (iofopen.c:73)
==9594==    by 0x40BE70A: fopen@@GLIBC_2.1 (iofopen.c:103)
==9594==    by 0x8048729: downloadAndOpen (downloadAndOpen.c:12)
==9594==    by 0x80485B5: main (mtg.c:15)
==9594== 
==9594== LEAK …
Run Code Online (Sandbox Code Playgroud)

c stack-overflow valgrind coredump stack-smash

0
推荐指数
1
解决办法
3万
查看次数

浮点异常,没有浮点数或双变量

我遇到了以下代码"浮点异常,核心转储"的问题,但我甚至没有一个浮点数或双变量.通过使用检查printf,我观察到它发生在isPrimeFunction,执行阻塞.

/*
PROBLEM 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*/


#include <stdio.h>

typedef int bool;
const bool true=1;
const bool false=0;

bool isPrime(long long int number) {
    long long int i;
    for(i=2; i < (number/2); i++) {
        if(number%i == 0) {
            return false;
        }
    }
    return true;
}   

int main() {
    long long int number, largest;
    number=600851475143;
    largest=0;
    int i;

    for(i=1; i <= …
Run Code Online (Sandbox Code Playgroud)

c coredump floating-point-exceptions

0
推荐指数
1
解决办法
170
查看次数

segmentation fault (core dump) while loading a file

I am trying to create a function which loads data from a .txt file but when it runs I always get a segmentation fault(core dumped) error. The file contains an unknown number of lines while each line has a string and an integer separated by tab.The list_create function just creates a data structure. The while loop in the end deletes the data structure, I did not include the code because I am sure it does not cause the problem but …

c coredump file segmentation-fault

0
推荐指数
1
解决办法
62
查看次数

memset不使用指向字符的指针

以下代码有什么问题?memset应该与Pointer一起使用,以填充内存块.但此代码在控制台中显示分段错误(核心转储)的问题

#include<iostream>
#include <cstring>
using namespace std;

int main(int argc, char** argv)
{
    char* name = "SAMPLE TEXT";
    memset(name , '*', 6);
    cout << name << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

捕获分段错误的上述程序的屏幕截图

c++ coredump pointers c-strings memset

-1
推荐指数
1
解决办法
419
查看次数

为什么创建和写入非常大的向量会导致核心转储?

我正在创建一个Eratosthenes筛子,所以我可以看到所有素数到起始数字.只是下面的代码导致Rust 1.26上的核心转储.没有编译器警告或错误,并且核心转储对于没有错误消息也没有帮助.

fn main() {
    let starting_number: i64 = 600851475143;
    let mut primes = vec![true; 600851475143];

    primes[0] = false;
    primes[1] = false;

    for i in 2..((starting_number as f64).ln() as usize) {
        if primes[i] {
            let mut j = i + i;
            while j < primes.len() {
                primes[j] = false;
                j += i;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我认为Rust完全是为了安全并避免核心转储?这是一个合法的错误,我的代码没有被编译器捕获或不同的东西?

coredump rust

-1
推荐指数
1
解决办法
126
查看次数

使用 fscanf 读入指针时出现分段错误(核心转储)

我正在尝试使用 fscanf 来读取和打印屏幕上的每个字符,但是在运行程序时出现分段错误(核心转储)。这是我的代码:

#include <stdio.h>

main(int argc, char * argv[]) {
    int *a ;
    FILE *input;

    if (argc>=2) {
        input= fopen(argv[1],"r");

        if (input!=NULL) {
            while (feof(input)==0) {
                fscanf(input,"%d\n",a);
                printf("%d\n",*a);
            }
            fclose(input);
        } else {
            printf("Error!\n");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我提供文件作为参数,如下所示:

./myprog input.txt
Run Code Online (Sandbox Code Playgroud)

该文件input.txt包含以下内容:

23
47
55
70
Run Code Online (Sandbox Code Playgroud)

c coredump scanf segmentation-fault argv

-2
推荐指数
1
解决办法
4796
查看次数

arch linux intellij core dump

我的Intellij不会再开始了,我真的不知道为什么.继承日志文件:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f18a8424be0, pid=12079, tid=139743934207744
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x00007f18a8424be0
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you …
Run Code Online (Sandbox Code Playgroud)

coredump intellij-idea archlinux

-2
推荐指数
1
解决办法
987
查看次数

写入共享内存核心转储分段故障

我需要写共享内存,因此我有

#define FLAGS IPC_CREAT | 0644
int main() {
key = ftok("ex31.c", 'k');
shmid = shmget(key, 3, FLAGS);
shmaddr = shmat(shmid,0,0);    // THOSE LINES WORK AS EXPECTED

char* userInput = malloc(5);
read(0, userInput, 3);  // I want to read "b34" for example, WORKS GOOD
strcpy(shmaddr,userInput);   // THROWS EXCEPTION!
}
Run Code Online (Sandbox Code Playgroud)

它会抛出异常strcat,如果我删除它,则会在下一行抛出异常strcpy.我需要写入内存" b34\0"(4个字符),然后读取它.

c malloc coredump shared-memory backslash

-2
推荐指数
1
解决办法
228
查看次数

程序不应该按照"C faq"工作,但它有效

c-faq当我遇到这个页面时,我正在经历这个问题.我说以下程序将有一个核心转储:

struct list {
    char *item;
    struct list *next;
}

/* Here is the main program. */

main(argc, argv)
{}
Run Code Online (Sandbox Code Playgroud)

他们告诉核心转储发生的原因是:

结构声明结尾处缺少分号会导致main被声明为返回结构.(由于介入的注释,很难看到连接.)由于结构值函数通常是通过添加隐藏的返回指针来实现的(参见问题2.9),所以生成的main()代码尝试接受三个参数,尽管只有两个传递(在这种情况下,通过C启动代码).另见问题10.9和16.4.

虽然,当我跑这个节目在网上在这里,它的工作完美,程序也运行到最后.另外,当我使用gcc编译这个程序时,我没有收到任何警告.

我很惊讶,因为程序应该没有运行到最后.有人能告诉我为什么这个程序有效吗?如果它是正确的,为什么提到该程序将无法工作(任何可能崩溃的机会?).

注意:请不要发表评论如使用,int main因为我只是复制粘贴代码,而实际上,我使用正确的方法.

c coredump

-4
推荐指数
1
解决办法
181
查看次数