segmentation-fault

Segfault from adding a variable

。_饼干妹妹 提交于 2019-12-06 13:44:05
I'm admittedly a straight-C newbie, but this has got me stumped. I'm working on a linked list implementation for practice, and I'm getting a segfault by simply adding a variable to the split_node function: #include <stdio.h> #include <string.h> #include <stdlib.h> struct Node { struct Node *child; char *content; }; void print_list(struct Node node); void split_node(struct Node *node, int position); int main() { struct Node head, second, third; head.content = "first"; second.content = "second"; third.content = "i'm third"; head.child = &second; second.child = &third; print_list(head); split

Segmentation fault (core dumped) Error

删除回忆录丶 提交于 2019-12-06 13:18:43
问题 My program compiles fines but upon inputting a file I get a "Segmentation fault (core dumped)" error. Am I not handling the ostream correctly? #include <std_lib_facilities.h> struct Reading { int hour; double temperature; Reading(int h, double t): hour(h), temperature(t) { } bool operator<(const Reading &r) const; }; bool Reading::operator<(const Reading &r) const { // stub version if (temperature < r.temperature){ return true; } else if (r.temperature < temperature) { return false; } } /* *

Using a pointer to a dynamic 2D Array within a struct

微笑、不失礼 提交于 2019-12-06 13:18:42
问题 I have been writing a piece of code for my coursework in electromagnetic simulation and I have run into a problem. I decided to do a bit extra by expanding the original calculations to really large meshes of up to 10^8 elements, so now I have to use malloc(). So far, so good, but since I prefer to keep my code in libraries and then compile with the inline option of the compiler, I needed a way to pass information between functions. So, I started using structs to keep track of the parameters

Segmentation Fault executing pm on android

醉酒当歌 提交于 2019-12-06 13:04:11
I am able to execute pm from the adb shell fine, but I get a segmentation fault if I try and execute it from the terminal. I have read this thread which suggests a similar problem, but their solution doesn't seem to work. The stack trace is as follows: 01-22 04:04:39.356: D/AndroidRuntime(5059): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 01-22 04:04:39.356: D/AndroidRuntime(5059): CheckJNI is OFF 01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away 01-22 04:04:39.366: E/dalvikvm(5059): /system/framework/ext.jar odex has stale dependencies 01-22 04:04:39

Python threads stack_size and segfaults

别说谁变了你拦得住时间么 提交于 2019-12-06 11:57:47
A web crawler script that spawns at most 500 threads and each thread basically requests for certain data served from the remote server, which each server's reply is different in content and size from others. i'm setting stack_size as 756K's for threads threading.stack_size(756*1024) which enables me to have the sufficient number of threads required and complete most of the jobs and requests. But as some servers' responses are bigger than others, and when a thread gets that kind of response, script dies with SIGSEGV. stack_sizes more than 756K makes it impossible to have the required number of

Armadillo + Matlab Mex segfault

强颜欢笑 提交于 2019-12-06 11:50:21
I fiddled with this the whole day, so I thought I might make everyone benefit from my experience, please see my answer below. I first had a problem with running a compiled Mex file within Matlab, because Matlab complained that it couldn't open the shared library libarmadillo . I solved this using the environment variables LD_LIBRARY_PATH and LD_RUN_PATH ( DYLD_LIBRARY_PATH and LYLD_RUN_PATH in osx). The problem remained however, that a simple test file would segfault at runtime even though the exact same code would compile and run fine outside Matlab (not Mex'd). The segfault seems to be

Get a segment fault while reading a file

拟墨画扇 提交于 2019-12-06 09:39:34
I want to read the whole file content and print it out , but I get a segment fault , I can't find what's wrong with the code ... #include <stdio.h> #include <stdlib.h> int main() { FILE * file; long fsize; file = fopen("./input.txt","r"); if(file != NULL){ //get file size fseek(file,0,SEEK_END); fsize = ftell(file); rewind(file); // print char * file_content; fgets(file_content,fsize,file); puts(file_content); } else{ printf("open failure\n"); } fclose(file); return 0; } The pointer you pass to fgets ( file_content ) is uninitialized. It should be pointing to a block of memory large enough to

Ad Hoc iPhone SIGSEGV crash while Debug on device & simulator works

旧巷老猫 提交于 2019-12-06 08:27:36
App crashes immediately after I attempt to login so it can’t a be a watchdog memory issue Reason: _mh_execute_header App crashes upon attempting to make a network request using ASIHTTPRequest. Request never touches server. ASIHTTPRequest: I use -fno-objc-arc to omit ASIHTTPRequest from ARC. I believe that the following call is causing my problems since my call never even touches the server when I make a request. Any help would be greatly appreciated! Call: NSDictionary *response = [[NetworkManager sharedManager] loginWithName:name password:pwd]; Method: - (NSDictionary *)loginWithName:

segmentation fault in overloading operator =

徘徊边缘 提交于 2019-12-06 07:22:29
I just got a seg fault in overloading the assignment operator for a class FeatureRandomCounts, which has _rects as its pointer member pointing to an array of FeatureCount and size rhs._dim, and whose other date members are non-pointers: FeatureRandomCounts & FeatureRandomCounts::operator=(const FeatureRandomCounts &rhs) { if (_rects) delete [] _rects; *this = rhs; // segment fault _rects = new FeatureCount [rhs._dim]; for (int i = 0; i < rhs._dim; i++) { _rects[i]=rhs._rects[i]; } return *this; } Does someone have some clue? Thanks and regards! As mentioned, you have infinite recursion;

Segmentation fault with ulimit set correctly

試著忘記壹切 提交于 2019-12-06 07:21:24
I tried to help an OP on this question . I found out that a code like the one below causes segmentation fault randomly even if the stack is set to 2000 Kbytes. int main () { int a[510000]; a[509999] = 1; printf("%d", a[509999]); return 0; } As you can see the array is 510000 x 4 bytes = 2040000 bytes. The stack is set to 2000 Kbytes (2048000 bytes) using ulimit command: ulimit -s 2000 ulimit -Ss 2000 Based on those numbers the application has room to store the array, but randomly it return segmentation fault. Any ideas? There's a few reasons why you can't do this. There are things that are