Browse files

Workaround double free problems

The source code for handling images has a double free problem. Recent versions
of the GNU libc have a mechanism to automagically abort the program in such a
case. This causes Mosaic to crash if images are displayed.

I work around this issue by turning of automatical program abortion with a call
to mallopt().
  • Loading branch information...
1 parent 1e53bc1 commit 2b5f8dcd61c1ba594a5c80ec470d3bb6378f660d @fuzxxl fuzxxl committed Mar 9, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/main.c
View
9 src/main.c
@@ -71,6 +71,7 @@
#include <signal.h>
#include <sys/utsname.h>
#include <string.h>
+#include <malloc.h>
/* swp */
#define _KCMS_H_
@@ -231,6 +232,14 @@ main (int argc, char **argv, char **envp)
/* Since we're doing lots of TCP, just ignore SIGPIPE altogether. */
signal (SIGPIPE, SIG_IGN);
+#ifdef M_CHECK_ACTION
+ /* some code here has the habit of freeing pointers twice. The glibc
+ catches this and causes the program to abort. In order to make the
+ code somehow work, we turn aborting the program off. */
+
+ mallopt(M_CHECK_ACTION,5);
+#endif
+
InitChildProcessor();
MoCCIPreInitialize();

0 comments on commit 2b5f8dc

Please sign in to comment.