segmentation-fault

The largest size of 2-D array in C [duplicate]

孤人 提交于 2019-12-12 04:55:46
问题 This question already has an answer here : Segmentation Fault, large arrays (1 answer) Closed 5 years ago . in my C program, when I am taking an array like this int a[100000][100000]; I am getting segmentation fault. Now if I am using array of size less than 1000 * 1000 , like this int a[1000][1000]; I am not getting any problem.In my program I need to use a 10^5 * 10^5 array. What should I do to fix it . 回答1: Dynamically allocate it with malloc . By declaring it statically you use the stack,

How to pass a double pointer to a function without segmentation fault C language

半城伤御伤魂 提交于 2019-12-12 04:54:04
问题 I'm trying to pass a double pointer as an argument to a function and I can't see why the segmentation fault happen... Here is the function: void create_path_list(char *path_, char ***path) { // Convert the path (string) into a list of directories char *token = NULL; int i = 0; *path = (char **) realloc(*path, (i + 1) * sizeof(char *)); (*path)[i] = (char *) malloc(2); strcpy((*path)[0], "/"); for(token = strtok(path_,"/"), i = 1; token != NULL; token = strtok(NULL, "/"), ++i) { *path = (char

Spirit parser segfaults

丶灬走出姿态 提交于 2019-12-12 04:38:14
问题 I'm getting a segfault when I run this. It looks like the debug prints, but when I debug it I just get an endless loop of backtrace. If anyone can help point me in the right direction, I'd appreciate it. I'd also appreciate, if possible any tips/tricks for cleaning up this grammar. Thanks! //code here: /*** *I-EBNF parser * *This defines a grammar for BNF. */ //Speeds up compilation times. //This is a relatively small grammar, this is useful. #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS

Segmentation fault on two dimensional vector

Deadly 提交于 2019-12-12 04:37:14
问题 I have a file that contains values in a table format. The number of rows and columns in the file may vary. 33829731.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 205282038.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 3021548.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 203294496.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00 -1.00

QNetworkReply causes segfault

时间秒杀一切 提交于 2019-12-12 04:32:57
问题 I'm trying to write some kind of API client for PyQt4-based app. And, following this documentation i wrote this code: from PyQt4 import QtCore, QtNetwork class API(QtCore.QObject): def processResponse(self, response): print 'response' response.deleteLater() def processError(self, error): print 'error' def authenticate(self, authUrl, login, password): manager = QtNetwork.QNetworkAccessManager() request = QtNetwork.QNetworkRequest(QtCore.QUrl(authUrl)) reply = manager.get(request) reply.error

Linux - Memory Mapped File

与世无争的帅哥 提交于 2019-12-12 04:18:26
问题 I am trying to implement the caesar cipher with mmap. I think the cipher works so fine but the problem is, the mmap. The idea of it is to update the file, if there was a change. So far it isn't working. I can just read the memory mapped file and print it. But if I make any modificaiton, I get a segmentation fault. Unfortunately, I couldn't solve the problem myself. So, I would appreciate it, if you could help me with it. Here is the code. int main (int argc, char *argv[]) { if(argc != 5)

C fopen seg fault

不问归期 提交于 2019-12-12 04:18:19
问题 I have a program that takes two parameters, an integer and a string. The first represents the number of lines to be read from the file, whose name is the second arg. Files have an integer value per line. int main(int argc, char* argv[]) { // the size of the data set long dataSize = atol(argv[1]); // an array to store the integers from the file long dataSet[dataSize]; // open the file fp = fopen(argv[2], "r"); // exit the program if unable to open file if(fp == NULL) { printf("Couldn't open

malloc() seg fault in localtime()?

我们两清 提交于 2019-12-12 04:13:18
问题 Here's ny stack malloc() at 0xb7dfd333 strdup() at 0xb7e01866 tzset_internal() at 0xb7e2ef68 __tz_convert() at 0xb7e2f26a localtime() at 0xb7e2d901 Send_Trace() at my_trace.c:265 0x8053373 and here's the offending code .. void Send_Trace(const char const *Trace_Text, ...) { time_t time_now = time(NULL); tm = *localtime(&time_now); It is generally working fine, but occassionally throws the seg fault shown above. Any ideas? 回答1: Any ideas? Any crash inside malloc or free is in 99.999% of cases

JNI segfaults creating new object

我们两清 提交于 2019-12-12 04:11:06
问题 I'm new to JNI (and java), so I apologize in advance if this is just a stupid mistake. But after much searching I can't find an explanation or a solution. I have a parametric Java class called Tagged<T> . The Java constructor for Tagged<T> takes an object T and a long ptr . The C code has a value and is supposed to create a Tagged object with the value v and the memory address of that value. However, I get a segfault when I call NewObject. Not sure if the problem is the generic Type

iOS: Segmentation fault crash, repeatable but debugger breaks into assembly

落花浮王杯 提交于 2019-12-12 04:07:59
问题 I've got a crash bug in our game that I've been trying to figure out for a long time, and haven't made much of any progress on. I've got a mostly repeatable set of steps to cause it, I've been able to reproduce it while tethered, figured out what the last bit of my code that's called before it happens. I've set break points and stepped through it... but when the crash happens, it's always just in the assembly and the crash reports always seem to come from within the run loop which isn't very