strtok segmentation fault

The problem is that you’re attempting to modify a string literal. Doing so causes your program’s behavior to be undefined. Saying that you’re not allowed to modify a string literal is an oversimplification. Saying that string literals are const is incorrect; they’re not. WARNING : Digression follows. The string literal “this is a test” is … Read more

Segmentation Fault in strcpy()

Your typedef defines Truck as a struct struck *, i.e. a pointer. So it’s size will be 4 or 8 depending on the architecture and not the size of the struct Use sizeof(*Truck) to get the actual size of the struct. You also need to allocate memory for the characters. The easiest way would be … Read more

Segmentation Fault before main

I’ve been running into a problem where somehow my code is causing segmentation faults before any of my main actually runs. Usually, this means that the data structures that your main tries to place in the automatic storage area overflow the stack. In your situation, it looks like the GRAPH is a suitable suspect to … Read more

Java VM: reproducible SIGSEGV on both 1.6.0_17 and 1.6.0_18, how to report?

I got similar problem upgrading to JDK 1.6_18 and it seems solved using the following options: -server -Xms256m -Xmx748m -XX:MaxPermSize=128m -verbose:gc -XX:+PrintGCTimeStamps -Xloggc:/tmp/gc.log -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=”/tmp” -XX:+UseParallelGC -XX:-UseGCOverheadLimit # Following options just to remote monitoring with jconsole, useful to see JVM behaviour at runtime -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=MyHost I still didn’t double check … Read more

casting char[][] to char** causes segfault?

A char[ROWS][COLS+1] cannot be cast into a char**. The input argument of print_map should be void print_map(char map[][COLS+1]) or void print_map(char (*map)[COLS+1]) The difference being that a char** means to point to something that can be dereferenced like this: (char**)map | v +——–+——–+——+——–+– … | 0x1200 | 0x1238 | NULL | 0x1200 | +—-|—+—-|—+–|—+—-|—+– … … Read more

Segmentation fault at glGenVertexArrays( 1, &vao );

glewExperimental = GL_TRUE; glewInit(); Should do the magic Experimental Drivers GLEW obtains information on the supported extensions from the graphics driver. Experimental or pre-release drivers, however, might not report every available extension through the standard mechanism, in which case GLEW will report it unsupported. To circumvent this situation, the glewExperimental global switch can be turned … Read more

Returning pointer from a function

Allocate memory before using the pointer. If you don’t allocate memory *point = 12 is undefined behavior. int *fun() { int *point = malloc(sizeof *point); /* Mandatory. */ *point=12; return point; } Also your printf is wrong. You need to dereference (*) the pointer. printf(“%d”, *ptr); ^