segmentation-fault

Can't find mistake — 'segmentation fault' - in C

巧了我就是萌 提交于 2019-12-25 18:58:16
问题 I wrote this function but can't get on the problem that gives me 'segmentation fault' msg. Thank you for any help guys !! /*This function extract all header files in a *.c1 file*/ void includes_extractor(FILE *c1_fp, char *c1_file_name ,int c1_file_str_len ) { int i=0; FILE *c2_fp , *header_fp; char ch, *c2_file_name,header_name[80]; /* we can assume line length 80 chars MAX*/ char inc_name[]="include"; char inc_chk[INCLUDE_LEN+1]; /*INCLUDE_LEN is defined | +1 for null*/ /* making the c2

Segmentation fault when parsing c string into pointer array

≯℡__Kan透↙ 提交于 2019-12-25 18:48:27
问题 The function makearg is supposed to count the number of words in a char array and also break each word up into their own spot in a pointer array. Segmentation fault seems to be a problem with the strncpy function. int makearg(char s[], char ***args); int main(){ char **args = (char**)(malloc(100)); char *str = "ls is a -l file"; int argc; argc = makearg(str, &args); printf("%d", argc); printf("%c", '\0'); int i; for(i = 0; i < argc; i++){ puts(args); printf("%c", '\n'); } return 0; } ////////

glGenBuffers crashing with Segmentation fault [closed]

a 夏天 提交于 2019-12-25 18:41:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I can't figure out why it keeps crashing on glGenBuffers GDB backtrace gives me this #0 0x00000000 in ?? () #1 0x0808701d in setupBuffers () at main_scene.cc:250 #2 0x08088cf8 in main (argc=1, argv=0xbffff3c4) at main_scene.cc:694 Here is my main() int main(int argc, char **argv) { glutInit(&argc, argv);

Fixing a Segmentation fault: 11

本小妞迷上赌 提交于 2019-12-25 18:14:09
问题 I'm currently trying to convert an integer string (like "509" as type char) to an int in C. However once I added the portion of code that checked to see if the value should be negative I get a segmentation error. I tried doing some research and found that its because of using pointers wrong or accessing memory I don't have permission to. But I can't seem to figure out where I'm going wrong. This is my first C class so I am new to it, any help would be much appreciated. Thanks! #include <stdio

writing to stdout throws segmentation fault in fortran

强颜欢笑 提交于 2019-12-25 16:54:40
问题 I working with some legacy code, but I'm running into a seg fault. Analyzing the core dump with gdb gives Program terminated with signal 11, Segmentation fault. #0 0x00000000007d2200 in se_fly (iq=0) at se.f90:384 384 WRITE(stdout,'(/5x,a)') repeat('=',67) What is strange to me is that I've run this piece of code with different initial conditions without issues, so I suspect that I've hit a memory wall but the core dump analysis seems to suggest otherwise. EDIT: compiled with ifort 14.0.0 来源:

Malloc statement giving segmentation fault 11

百般思念 提交于 2019-12-25 16:45:03
问题 For a project I am learning to use malloc/realloc in c, but I cannot figure out why this code gives me a seg fault! #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct word_data word_data_t; typedef struct data data_t; typedef struct index_data index_data_t; struct word_data { int docunumber; int freq; }; struct data { char *word; int total_docs; word_data_t *data; }; struct index_data { data_t *index_data_array; }; /* Inside a function called from

c - Segmentation fault when trying to write a modified structure

↘锁芯ラ 提交于 2019-12-25 16:43:47
问题 This is in a program meant to work with ppm image files. I'm getting a compilation error when trying to modify a struct and then writing it to a new file. This is the global struct (declared in ppmIO.c and ppmIO.h): ppmIO.c: struct Image *instance; ppmIO.h: struct Image { int width; int height; unsigned char *data; }; extern struct Image *instance; This is my imageManip.h file: #include <ppmIO.h> void ImageInvert(struct Image **toInvert); void ImageSwap(struct Image **toSwap); These are the

Why am I getting a segmentation fault in my C server program (but only sometimes)?

亡梦爱人 提交于 2019-12-25 15:15:50
问题 Right now, I'm trying to write a simple client/server application in order to measure the round trip time on a LAN for TCP messages of various sizes (I'm doing the timing client side). The program works fine for small packet sizes (> 1000 bytes) but I end up with a segmentation fault: 11 error for inputs of larger magnitude (10KB or greater). int main() { struct sockaddr_in sin; char buf[MAX_LINE]; int len; int s, new_s; /* build address data structure */ bzero((char *)& sin, sizeof( sin));

Error: “Fatal signal 11 (SIGSEGV), code 1” when passing Mat object from java to jni function

旧城冷巷雨未停 提交于 2019-12-25 11:14:55
问题 I am running the video camera using the OpenCV function. I pass the Mat object to the jni function it works for awhile, them the error: 10-10 13:03:17.978: A/libc(28693): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x9 in tid 28791 (Thread-5418) Java code that runs the camera and calls the jni function: package com.adhamenaya; import java.util.ArrayList; import org.opencv.android.BaseLoaderCallback; import org.opencv.android.CameraBridgeViewBase; import org.opencv.android

MPI C - Gather 2d Array Segments into One Global Array

旧巷老猫 提交于 2019-12-25 09:19:51
问题 I am trying to print a dynamically allocated 2d array from my master process after receiving all its components from all other processes. By components I mean subarrays, or blocks. I have made the code generic to the number of processes. The following diagram will help you see how the blocks are arranged in the complete array. Each block is handled by one process. Just for here though, let's assume that i run the program using 12 processes (natively i have 8 cores), using the command: mpiexec