segmentation-fault

Working around segmentation faults that occur in parallel due to a non-thread-safe API function

[亡魂溺海] 提交于 2019-12-12 02:58:06
问题 I am currently coding a MEX file in MATLAB to run experiments in parallel using the parfor function in MATLAB 2012a. The MEX file does some very straightforward numerical tasks but relies on the CPLEX 12.4 API from IBM. Although my MEX file works sequentially, I will inevitably receive "random" segmentation fault when I run in in parallel. After sending a stack trace of the segmentation fault to MATLAB, they have suggested that the error originates from the "putenv()" function from the C

Memory violation: SIGSEGV and 'can't find linker symbol for virtual table…'

随声附和 提交于 2019-12-12 02:49:44
问题 I struggle with a memory violation error in my C++ code, and it makes me crazy. I have to use some existing classes and they work fine almost everywhere else. I am trying to make a copy of a custom Array object, than modify inner values later. But there is something wrong with that copy operation... The symptoms are the following: Segmentation fault after the copy, but not immediately Warning: can't find linker symbol for virtual table for 'MyClass<T>' value MyClass<T> has nothing to do with

Segmentation fault on library call

不问归期 提交于 2019-12-12 02:48:15
问题 I'm using a physics library called Chipmunk for a game that I'm writing. In my initialize function I initialize the global variable cpSpace space . Then in update I call cpSpaceStep(space, timestep) . The prototype for this function is void cpSpaceStep(cpSpace *space, cpFloat dt); . I'm getting a segfault on this function call. I've marked those two function calls in the code below. The full code is below: #include "../include/SDL/SDL_image.h" #include "../include/SDL/SDL.h" #include "..

Segmentation error while replacing substrings of a string with other substring

[亡魂溺海] 提交于 2019-12-12 02:45:25
问题 I have string " {"1":"[4,11,14,19,20,18,27]"} ". I want to change it into "{\"1\":\"4,11,14,19,20,18,27\"}". Below is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> char *replace (char *this, char *withthat, char *inthis) { char *where = inthis; while ((where = strstr(where, this))) { memcpy(where, withthat, strlen(withthat)); memmove(where+strlen(withthat),where+strlen(this), strlen(where+strlen(this))+1); } return inthis; } int main(void) { char string[] = "{"1":"[4,11

segmentation fault when creating connect 4 board c program

旧时模样 提交于 2019-12-12 02:27:21
问题 I'm creating a connect-4 game... I have a lot of it done; however, the way I was creating my board was static & it needed to be dynamic, so I've made a side program to fix this before implementing it in my main program. For some reason, the if & else-if conditionals in this chunk of code create a segmentation fault, and I can't figure out why... // for the rows/columns of the board for(row = num_rows - 1; row >= 0; row--){ printf("|"); for(col = 0; col < num_columns; col++){ if(aPtr[row][col]

arrays using pointers in c++: segmentation fault when accessing the returned array

一个人想着一个人 提交于 2019-12-12 02:19:40
问题 I'm new to C++ and I'm trying to build a 3 dimensional array using a pointer to a pointer to a pointer. I am sure there are more efficient ways in doing so, but I am trying to understand pointers at the moment. As example code, I originally had the following piece, which worked fine, allocating, initializing, and releasing the memory. void builder(int aSize1, int aSize2, int aSize3) { int i1, i2, i3; int ***frequencies; cout << "allocation started ..." << endl; frequencies = new int** [aSize1

I have segfaults!

怎甘沉沦 提交于 2019-12-12 02:16:36
问题 Today is my first time using c++ in a while. I am normally a python programmer. I keep getting segfaults and I've isolated it to the commented lines. (the ones that are commented cause segfaults when uncommented.) #include <iostream> #include <fstream> #include <string> using namespace std; #include "defaultfile.h" int main() { ifstream mapin; string map; string s; int i = 0; while (i<=22){i++;top[i][0]="__";i++;};i=0; while (i<=21){i++;frw[i][0]="/";i++;};i=0; while (i<=21){i++;bck[i][0]="\\

Why don't I get SIGSEGV? [duplicate]

倖福魔咒の 提交于 2019-12-12 01:53:16
问题 This question already has answers here : Array index out of bound in C (10 answers) Is accessing a global array outside its bound undefined behavior? (8 answers) Closed 4 years ago . I would like to understand what is going on here, more precisely why I do NOT receive a segmentation fault while writing on a memory location, which according to my understanding is not allocated. Let's say I want to define a 2D array of int ( testptr ). One dimension ( 4 ) is allocated statically (as an "array")

segfault with array

扶醉桌前 提交于 2019-12-12 01:35:31
问题 I have two questions regarding array: First one is regarding following code: int a[30]; //1 a[40]=1; //2 why isn't the line 2 giving segfault, it should give because array has been allocated only 30 int space and any dereferencing outside its allocated space should give segfault. Second: assuming that above code works is there any chance that a[40] will get over written, since it doesn't come is the reserved range of arrray. Thanks in advance. 回答1: That's undefined behavior - it may crash, it

Can't figure out Segmentation Fault for C++ code

ⅰ亾dé卋堺 提交于 2019-12-12 01:28:01
问题 My code is below. The problem happens when I try and run the addArray() function. I am completely new to C++ so I have no idea what a segmentation fault means. I also know that there is probably a better way to initialize and return the 2d arrays, but I am slowly figuring that out. My main problem now is the segmentation fault. I am guessing that it has something to do with how I am accessing the variables? #include <iostream> #include <cstdlib> #include <iostream> #include <vector> #include