My code compiles and runs fine in my IDE. However, when I use gcc to compile and then run my a.out file it says Segmentation fault (core dumped).
(edited to include my code)
In main.c I have commented out all of my code and it still causes seg fault.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include "BmpProcessor.h"
#include "PixelProcessor.h"
#include "PpmProcessor.h"
#include "debug.h"
#define THREAD_COUNT 8;
int main(int argc, char *argv[]) {
/** commented out all of my code */
return 0;
}
Any ideas why? None of my other files that I include have a main method.
DEBUGGING DETAILS
gcc -g -Wall -pedantic -o PurdyImageProcessor PurdyImageProcessor.c BmpProcessor.c PpmProcessor.c PixelProcessor.c -lm -pthread
PixelProcessor.c: In function ‘boxBlurMultithreading’:
PixelProcessor.c:437:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
PixelProcessor.c: In function ‘cheesifyMultithreading’:
PixelProcessor.c:487:1: warning: control reaches end of non-void function [-Wreturn-type]
}
Advertisement
Answer
We need more information. Please do the following:
Recompile with “-g”, for debugging information. Include “-Wall -pedantic” for additional compiler warnings
EXAMPLE:
gcc -g -Wall -pedantic -o myprog myprog.c
Update your post with your “gcc” command, and the compiler warnings you get.
Run your program. If it still crashes, use gdb to analyze further:
EXAMPLE:
gdb ./myprog
Type “r” to execute. Type “bt” to get a stack trace after it crashes. Copy/paste the stack trace into your post.
Here are several useful links: