[Mono-dev] malloc error executing OBS-built mono

Miguel González mgonzalez at codicesoftware.com
Tue Oct 20 16:29:41 UTC 2015


Hi,

I have a setup of OBS (SUSE Open Build Service) machines where I create OpenSUSE 12.3 RPM packages of mono 4.3 and GTK# 2.12.29. I'm using code downloaded from http://github.com/mono/mono at commit b6dfce621f70115cd16e75a743cbbdee5ac6610e.

To make the code compile without complains from the OBS worker machine I had to apply this fix:

--- mono/mcs/class/corlib/System/WindowsConsoleDriver.cs      2015-10-14 18:14:36.238365556 +0200
+++ mono/mcs/class/corlib/System/WindowsConsoleDriver.cs      2015-10-15 12:14:12.750179775 +0200
@@ -432,7 +432,7 @@
                    Coord bsize = new Coord (sourceWidth, sourceHeight);
                    Coord bpos = new Coord (0, 0);
                    SmallRect region = new SmallRect (sourceLeft, sourceTop, sourceLeft + sourceWidth - 1, sourceTop + sourceHeight - 1);
-                    fixed (void *ptr = &buffer [0]) {
+                    fixed (CharInfo *ptr = &buffer [0]) {
                          if (!ReadConsoleOutput (outputHandle, ptr, bsize, bpos, ref region))
                                 throw new ArgumentException (String.Empty, "Cannot read from the specified coordinates.");
                    }

I also had to apply this change in order to avoid an unallowed warning message:
I: Statement might be overflowing a buffer in strncat. Common mistake:
   BAD: strncat(buffer,charptr,sizeof(buffer)) is wrong, it takes the
   left over size as 3rd argument
   GOOD: strncat(buffer,charptr,sizeof(buffer)-strlen(buffer)-1)

(bufferoverflowstrncat)

--- mono/mono/metadata/process.c  2015-10-14 18:21:22.283225690 +0200
+++ mono/mono/metadata/process.c  2015-10-20 11:42:45.094099600 +0200
@@ -383,7 +383,7 @@
      char filename [80] = "[In Memory] ";
      const char *modulename = assembly->aname.name;
-      strncat (filename, modulename, 80);
+      strncat (filename, modulename, 80 - strlen(filename) - 1);
       /* Build a System.Diagnostics.ProcessModule with the data.
       */

First of all, does this last change make sense? I'd say so -since it's the expected strncat usage- but I'm not completely sure.

At this point I'm able to build mono RPM packages and they're working as I install them using a test OpenSUSE 12.3 virtual machine. However, when the GTK# builds are started -which use the mono packages as build requirement-, the worker is unable to run the mono executable: apparently, malloc is corrupting the heap or something. This is a sample execution as extracted from the OBS build logs:

[  101s] + /opt/plasticscm5/mono/bin/mono /opt/plasticscm5/mono/lib/mono/4.5/gacutil.exe -l

[  101s] *** Error in `/opt/plasticscm5/mono/bin/mono': malloc: top chunk is corrupt: 0x08ab9230 ***
As you might guess, the --prefix value used to compile mono is /opt/plasticscm5/mono) The MALLOC_CHECK_ environment variable is set to 3 by default. If set to 1, a warning message is displayed and the execution continues, but the program ends incorrectly by a segmentation fault.


I'm totally clueless about what might be happening. I have OBS configured to build this exact packages on OpenSUSE 12.2 and (to my dismay) they are being built flawlessly.
Could this be caused by my custom code changes? I don't think that's the cause since all of the remaining distros (Debian 6/8, Ubuntu 14.04, Red Hat 6, Fedora 17/20 and OpenSUSE 12.2) don't reproduce the issue.

I'd be delighted if someone could give me a hint about what might be going on. I'm also available to post any additional information that may be useful to find out the reason behind my mess.

Thank you!

Miguel González


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20151020/f2645a52/attachment.html>


More information about the Mono-devel-list mailing list