segmentation-fault

How to conceal a segmentation fault in a bash script

北城以北 提交于 2020-01-24 09:56:26
问题 I use a program that works properly and results in desirable output at the end of its operation with no memory leak or any other specific issue, but then it issues a segmentation fault at the point it exits. I have been trying to hide this harmless but annoying error from the end user when using this program by redirecting the standard error to Null: program options >file 2>/dev/null But this doesn't work and the error shows up in the middle of the script's outputs each time I run the program

Dwarf Error: Cannot find DIE

冷暖自知 提交于 2020-01-23 08:36:25
问题 I am having a lot of trouble debugging a segmentation fault in a C++ project in XCode 4. I only get a segfault when I built with the "LLVM 2.0" compiler option and use -O3 optimization. From what I understand, there are limited debugging options when one is using optimization, but here is the debug output I get after I run in Xcode with gdb turned on: warning: Got an error handling event: "Dwarf Error: Cannot find DIE at 0x3be2 referenced from DIE at 0x11d [in module /Users/imran/Library

PyCharm debug segmentation fault (signal 11)

半腔热情 提交于 2020-01-22 17:48:07
问题 In PyCharm (community edition 2016.2.3), using anaconda2 + ubuntu 14.04, import matplotlib causes a signal 11 error during the debug mode. There is no problem when executing the script in release mode. The python code: import matplotlib as pt The debug console: Connected to pydev debugger (build 162.1967.10) GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications. Backend Qt4Agg is interactive backend. Turning interactive mode

C pointer pointer, and seg fault

萝らか妹 提交于 2020-01-21 19:22:12
问题 Below is my simple linked list in C. My question is in "headRef = &newNode;" which causes segmentation fault. Then I tried instead "*headRef = newNode;" which resolves the seg fault problem. Though the two lines of code seem to me to work in the same way, why is one causing seg fault and the other one not? Thanks in advance. struct node{ int data; struct node* next; }; void Push(struct node** headRef, int data){ struct node* newNode = malloc(sizeof(struct node)); if(!newNode) return; newNode-

Seg Fault when initializing array

会有一股神秘感。 提交于 2020-01-19 14:03:28
问题 I'm taking a class on C, and running into a segmentation fault. From what I understand, seg faults are supposed to occur when you're accessing memory that hasn't been allocated, or otherwise outside the bounds. 'Course all I'm trying to do is initialize an array (though rather large at that) Am I simply misunderstanding how to parse a 2d array? Misplacing a bound is exactly what would cause a seg fault-- am I wrong in using a nested for-loop for this? The professor provided the clock

Seg Fault when initializing array

我与影子孤独终老i 提交于 2020-01-19 14:02:28
问题 I'm taking a class on C, and running into a segmentation fault. From what I understand, seg faults are supposed to occur when you're accessing memory that hasn't been allocated, or otherwise outside the bounds. 'Course all I'm trying to do is initialize an array (though rather large at that) Am I simply misunderstanding how to parse a 2d array? Misplacing a bound is exactly what would cause a seg fault-- am I wrong in using a nested for-loop for this? The professor provided the clock

Sprintf Segmentation Fault

旧时模样 提交于 2020-01-19 09:58:08
问题 numCheck is number between 1-1000. This code gives me a segfault only when I collect the results of sprintf in charcheck. If I simply use sprintf without using the results, I don't get a seg fault. What's happening here? char * numString; int charcheck = sprintf(numString, "%d", numCheck); 回答1: You need to provide your own memory for sprintf . Also, don't use sprintf , but rather snprintf : char buf[1000] = {0}; snprintf(buf, 999, ....); Alternatively you can allocate memory dynamically: char

Why is this passing the if statement?

谁说胖子不能爱 提交于 2020-01-17 13:48:08
问题 Hello can someone help me find what is causing the problem? For some reason the find_hash function is giving me problems. It should be failing the if(table -> buckets_array[i] != NULL){ and if(table -> buckets_array[i] != '\0'){ but it is not and it going to the next check which gives me a segmentation fault. What can be causing the first 2 if's statement to pass since I initially set it to table -> buckets_array[i] = NULL? Edit: Thanks for wildplasser I came up with a much better solution

strcat causing segmentation fault

ⅰ亾dé卋堺 提交于 2020-01-17 03:58:09
问题 This causes a segmentation fault: char str1[60]; char**array; array=malloc( str_nos * sizeof(char *) ); array[i]=malloc( str_len * sizeof(char *) ); strcat(array[i],str1); strcat(array[i]," "); str1 is taken from scanf and it's shorter than 60 characters. array[i] is from a dynamic array of strings. Do you have any idea of what causes the problem? It happens only for a great amount of scanf s. 回答1: At least two possibilities: If the buffer pointed to by array[i] doesn't hold enough space,

Trouble creating a shell in C (Seg-Fault and ferror)

我的梦境 提交于 2020-01-16 05:14:16
问题 I have been following a tutorial on how to make my own shell but I have been stuck for a couple days now. Two things: When this code is compiled and ran, it will randomly have segmentation faults and I cannot figure out why. The if statement `if (ferror != 0)` always seems to be true. which is odd because I do not understand why fgets() is failing in the main() function. Any information on these topics (or other topics about creating this shell) would be greatly appreciated. #include <stdio.h