strlen not checking for NULL

The rational behind it is simple — how can you check the length of something that does not exist? Also, unlike “managed languages” there is no expectations the run time system will handle invalid data or data structures correctly. (This type of issue is exactly why more “modern” languages are more popular for non-computation or … Read more

Segfaults in malloc() and malloc_consolidate()

From http://www.gnu.org/s/libc/manual/html_node/Heap-Consistency-Checking.html#Heap-Consistency-Checking: Another possibility to check for and guard against bugs in the use of malloc, realloc and free is to set the environment variable MALLOC_CHECK_. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free with the same … 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

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

Capture “Segmentation fault” message for a crashed subprocess: no out and err after a call to communicate()

“Segmentation fault” message might be generated by a shell. To find out, whether the process is kill by SIGSEGV, check proc.returncode == -signal.SIGSEGV. If you want to see the message, you could run the command in the shell: #!/usr/bin/env python from subprocess import Popen, PIPE proc = Popen(shell_command, shell=True, stdout=PIPE, stderr=PIPE) out, err = proc.communicate() … Read more

tech