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

2015-10-23 Thread Greg Young
You will need to grab the valgrind suppression file as well.

https://github.com/mono/mono/blob/master/data/mono.supp

http://www.mono-project.com/docs/debug+profile/debug/

HTH,

Greg

On Thu, Oct 22, 2015 at 7:08 PM, Miguel de Icaza <mig...@xamarin.com> wrote:
> Hello,
>
> Well, the great news is that this happens without involving the JIT or GC -
> it happens just at startup, so this is a plain-old C bug.
>
> Your best bet is now to run this with Valgrind and see what it tells you.
>
> On Thu, Oct 22, 2015 at 12:04 PM, Miguel González
> <mgonza...@codicesoftware.com> wrote:
>>
>> I executed a sample command (gacutils.exe -l) under gdb to see the trace
>> at the time of the crash.
>>
>>
>>
>> This is the backtrace as returned by gdb:
>>
>>
>>
>> Program received signal SIGABRT, Aborted.
>>
>> 0xf7e1b245 in raise () from /lib/libc.so.6
>>
>> #0  0xf7e1b245 in raise () from /lib/libc.so.6
>>
>> #1  0xf7e1cac3 in abort () from /lib/libc.so.6
>>
>> #2  0xf7e635cb in malloc_printerr () from /lib/libc.so.6
>>
>> #3  0xf7e63aec in top_check () from /lib/libc.so.6
>>
>> #4  0xf7e65b13 in malloc_check () from /lib/libc.so.6
>>
>> #5  0xf7e66c45 in malloc () from /lib/libc.so.6
>>
>> #6  0xf7e6b071 in strdup () from /lib/libc.so.6
>>
>> #7  0x0827d54c in monoeg_g_strsplit ()
>>
>> #8  0x081b70a5 in arch_matches ()
>>
>> #9  0x081b70fa in arch_matches ()
>>
>> #10 0x081b7770 in dllmap_start ()
>>
>> #11 0x08283f42 in monoeg_g_markup_parse_context_parse ()
>>
>> #12 0x081b6e38 in mono_config_parse_xml_with_context ()
>>
>> #13 0x081b6f6d in mono_config_parse_file_with_context ()
>>
>> #14 0x081b6fd7 in mono_config_parse_file ()
>>
>> #15 0x081b808c in mono_config_parse ()
>>
>> #16 0x080c1449 in mono_main ()
>>
>> #17 0x08065e52 in main ()
>>
>>
>>
>> It seems to be failing when the /etc/mono/config file is loaded. This is
>> the config file contents. The zlib line has been manually added to the code
>> retrieved from GitHub.
>>
>> 
>>
>>
>>
>>
>>
>>
>>
>>> os="solaris"/>
>>
>>> os="solaris"/>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> target="$mono_libdir/libMonoPosixHelper.so" os="!windows" />
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> os="!windows"/>
>>
>>> os="!windows"/>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>    
>>
>>    > target="mono_win32_compat_CopyMemory"/>
>>
>>> target="mono_win32_compat_FillMemory"/>
>>
>>> target="mono_win32_compat_MoveMemory"/>
>>
>>> target="mono_win32_compat_ZeroMemory"/>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 
>>
>>
>>
>> Anyway, as I mentioned, we’re putting the openSUSE 12.3 build aside. We’ve
>> noticed that openSUSE 12.3, 13.1 and 13.2 can work with our openSUSE 12.2
>> repository.
>>
>>
>>
>> Miguel
>>
>>
>>
>> From: mono-devel-list-boun...@lists.ximian.com
>> [mailto:mono-devel-list-boun...@lists.ximian.com] On Behalf Of Miguel
>> González
>> Sent: 22 October 2015 10:49
>> To: Miguel de Icaza <mig...@xamarin.com>
>>
>>
>> Cc: mono-devel-list@lists.ximian.com
>> Subject: Re: [Mono-dev] malloc error executing OBS-built mono
>>
>>
>>
>> Hi Miguel,
>>
>>
>>
>> Thanks for the update :-) I had also an e-mail from Zoltan Varga yesterday
>> telling me that the change had been applied. I updated my code accordingly
>> to see if that could be the fix for my issue, too… But it didn’t :-(
>>
>>
>>
>> I’ll try using gdb as you suggested. I hadn’t considered it before since
>> this crash only happens inside the automated build of the OBS worker virtual
>> machine and I’ve not been able to reproduce in any other environment.
>> However, any additional info is always appreciated! There are also chances
>> of ditching this build and relying on other dis

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

2015-10-23 Thread Miguel de Icaza
08B: mono_config_parse (in
> /opt/plasticscm5/mono/bin/mono-sgen)
>
> ==4421==by 0x80C1448: mono_main (in
> /opt/plasticscm5/mono/bin/mono-sgen)
>
> ==4421==    by 0x8065E51: main (in /opt/plasticscm5/mono/bin/mono-sgen)
>
> ==4421==
>
> ==4421== ERROR SUMMARY: 130 errors from 130 contexts (suppressed: 0 from 0)
>
>
>
> I’ve attached the full report as a text file to this mail.
>
>
>
> Thanks!
>
>
>
> Miguel
>
>
>
> *From:* Miguel de Icaza [mailto:mig...@xamarin.com]
> *Sent:* 22 October 2015 18:09
>
> *To:* Miguel González <mgonza...@codicesoftware.com>
> *Cc:* mono-devel-list@lists.ximian.com
> *Subject:* Re: [Mono-dev] malloc error executing OBS-built mono
>
>
>
> Hello,
>
>
>
> Well, the great news is that this happens without involving the JIT or GC
> - it happens just at startup, so this is a plain-old C bug.
>
>
>
> Your best bet is now to run this with Valgrind and see what it tells you.
>
>
>
> On Thu, Oct 22, 2015 at 12:04 PM, Miguel González <
> mgonza...@codicesoftware.com> wrote:
>
> I executed a sample command (gacutils.exe -l) under gdb to see the trace
> at the time of the crash.
>
>
>
> This is the backtrace as returned by gdb:
>
>
>
> Program received signal SIGABRT, Aborted.
>
> 0xf7e1b245 in raise () from /lib/libc.so.6
>
> #0  0xf7e1b245 in raise () from /lib/libc.so.6
>
> #1  0xf7e1cac3 in abort () from /lib/libc.so.6
>
> #2  0xf7e635cb in malloc_printerr () from /lib/libc.so.6
>
> #3  0xf7e63aec in top_check () from /lib/libc.so.6
>
> #4  0xf7e65b13 in malloc_check () from /lib/libc.so.6
>
> #5  0xf7e66c45 in malloc () from /lib/libc.so.6
>
> #6  0xf7e6b071 in strdup () from /lib/libc.so.6
>
> #7  0x0827d54c in monoeg_g_strsplit ()
>
> #8  0x081b70a5 in arch_matches ()
>
> #9  0x081b70fa in arch_matches ()
>
> #10 0x081b7770 in dllmap_start ()
>
> #11 0x08283f42 in monoeg_g_markup_parse_context_parse ()
>
> #12 0x081b6e38 in mono_config_parse_xml_with_context ()
>
> #13 0x081b6f6d in mono_config_parse_file_with_context ()
>
> #14 0x081b6fd7 in mono_config_parse_file ()
>
> #15 0x081b808c in mono_config_parse ()
>
> #16 0x080c1449 in mono_main ()
>
> #17 0x08065e52 in main ()
>
>
>
> It seems to be failing when the /etc/mono/config file is loaded. This is
> the config file contents. The zlib line has been manually added to the code
> retrieved from GitHub.
>
> 
>
>
>
>
>
>
>
> os="solaris"/>
>
> os="solaris"/>
>
>
>
>
>
>
>
>
>
>
>
>
>
> target="$mono_libdir/libMonoPosixHelper.so" os="!windows" />
>
>    
>
>
>
>
>
>
>
>
>
> os="!windows"/>
>
> os="!windows"/>
>
>
>
>
>
>
>
>
>
>
>
>
>
> target="mono_win32_compat_CopyMemory"/>
>
> target="mono_win32_compat_FillMemory"/>
>
> target="mono_win32_compat_MoveMemory"/>
>
> target="mono_win32_compat_ZeroMemory"/>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 
>
>
>
> Anyway, as I mentioned, we’re putting the openSUSE 12.3 build aside. We’ve
> noticed that openSUSE 12.3, 13.1 and 13.2 can work with our openSUSE 12.2
> repository.
>
>
>
> Miguel
>
>
>
> *From:* mono-devel-list-boun...@lists.ximian.com [mailto:
> mono-devel-list-boun...@lists.ximian.com] *On Behalf Of *Miguel González
> *Sent:* 22 October 2015 10:49
> *To:* Miguel de Icaza <mig...@xamarin.com>
>
>
> *Cc:* mono-devel-list@lists.ximian.com
> *Subject:* Re: [Mono-dev] malloc error executing OBS-built mono
>
>
>
> Hi Miguel,
>
>
>
> Thanks for the update :-) I had also an e-mail from Zoltan Varga yesterday
> telling me that the change had been applied. I updated my code accordingly
> to see if that could be the fix for my issue, too… But it didn’t :-(
>
>
>
> I’ll try using gdb as you suggested. I hadn’t considered it before since
> this crash only happens inside the automated build of the OBS worker
> virtual machine and I’ve not been able to reproduce in any other
> environment. However, any additional info is always appreciated! There are
> also chances of ditching this build and relying on other distros to build
> our packages, since our OpenSUSE packages seem to be highly compatible
> between versions.
>
>
>
> Thank you,
>
>
>
> Mig

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

2015-10-22 Thread Miguel González
Hi Miguel,

Thanks for the update :-) I had also an e-mail from Zoltan Varga yesterday 
telling me that the change had been applied. I updated my code accordingly to 
see if that could be the fix for my issue, too… But it didn’t :-(

I’ll try using gdb as you suggested. I hadn’t considered it before since this 
crash only happens inside the automated build of the OBS worker virtual machine 
and I’ve not been able to reproduce in any other environment. However, any 
additional info is always appreciated! There are also chances of ditching this 
build and relying on other distros to build our packages, since our OpenSUSE 
packages seem to be highly compatible between versions.

Thank you,

Miguel

From: Miguel de Icaza [mailto:mig...@xamarin.com]
Sent: 21 October 2015 20:44
To: Miguel González <mgonza...@codicesoftware.com>
Cc: mono-devel-list@lists.ximian.com
Subject: Re: [Mono-dev] malloc error executing OBS-built mono

Hello Miguel,

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)

We replaced that code with the glib string operations just yesterday:

042ddd504c09977682bb48010c5642390826d1da

But thanks for sharing.

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 ***

What you want to do at this point in time is to run the process under gdb, as 
this will show where malloc detected the error, and then you should get both 
the unmanaged stack trace, and if possible the managed one (with the mono_stack 
gdb macro)

Miguel.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


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

2015-10-22 Thread Miguel González
I executed a sample command (gacutils.exe -l) under gdb to see the trace at the 
time of the crash.

This is the backtrace as returned by gdb:

Program received signal SIGABRT, Aborted.
0xf7e1b245 in raise () from /lib/libc.so.6
#0  0xf7e1b245 in raise () from /lib/libc.so.6
#1  0xf7e1cac3 in abort () from /lib/libc.so.6
#2  0xf7e635cb in malloc_printerr () from /lib/libc.so.6
#3  0xf7e63aec in top_check () from /lib/libc.so.6
#4  0xf7e65b13 in malloc_check () from /lib/libc.so.6
#5  0xf7e66c45 in malloc () from /lib/libc.so.6
#6  0xf7e6b071 in strdup () from /lib/libc.so.6
#7  0x0827d54c in monoeg_g_strsplit ()
#8  0x081b70a5 in arch_matches ()
#9  0x081b70fa in arch_matches ()
#10 0x081b7770 in dllmap_start ()
#11 0x08283f42 in monoeg_g_markup_parse_context_parse ()
#12 0x081b6e38 in mono_config_parse_xml_with_context ()
#13 0x081b6f6d in mono_config_parse_file_with_context ()
#14 0x081b6fd7 in mono_config_parse_file ()
#15 0x081b808c in mono_config_parse ()
#16 0x080c1449 in mono_main ()
#17 0x08065e52 in main ()

It seems to be failing when the /etc/mono/config file is loaded. This is the 
config file contents. The zlib line has been manually added to the code 
retrieved from GitHub.

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   


Anyway, as I mentioned, we’re putting the openSUSE 12.3 build aside. We’ve 
noticed that openSUSE 12.3, 13.1 and 13.2 can work with our openSUSE 12.2 
repository.

Miguel

From: mono-devel-list-boun...@lists.ximian.com 
[mailto:mono-devel-list-boun...@lists.ximian.com] On Behalf Of Miguel González
Sent: 22 October 2015 10:49
To: Miguel de Icaza <mig...@xamarin.com>
Cc: mono-devel-list@lists.ximian.com
Subject: Re: [Mono-dev] malloc error executing OBS-built mono

Hi Miguel,

Thanks for the update :-) I had also an e-mail from Zoltan Varga yesterday 
telling me that the change had been applied. I updated my code accordingly to 
see if that could be the fix for my issue, too… But it didn’t :-(

I’ll try using gdb as you suggested. I hadn’t considered it before since this 
crash only happens inside the automated build of the OBS worker virtual machine 
and I’ve not been able to reproduce in any other environment. However, any 
additional info is always appreciated! There are also chances of ditching this 
build and relying on other distros to build our packages, since our OpenSUSE 
packages seem to be highly compatible between versions.

Thank you,

Miguel

From: Miguel de Icaza [mailto:mig...@xamarin.com]
Sent: 21 October 2015 20:44
To: Miguel González 
<mgonza...@codicesoftware.com<mailto:mgonza...@codicesoftware.com>>
Cc: mono-devel-list@lists.ximian.com<mailto:mono-devel-list@lists.ximian.com>
Subject: Re: [Mono-dev] malloc error executing OBS-built mono

Hello Miguel,

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)

We replaced that code with the glib string operations just yesterday:

042ddd504c09977682bb48010c5642390826d1da

But thanks for sharing.

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 ***

What you want to do at this point in time is to run the process under gdb, as 
this will show where malloc detected the error, and then you should get both 
the unmanaged stack trace, and if possible the managed one (with the mono_stack 
gdb macro)

Miguel.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


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

2015-10-21 Thread Miguel de Icaza
Hello Miguel,

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)
>

We replaced that code with the glib string operations just yesterday:

042ddd504c09977682bb48010c5642390826d1da

But thanks for sharing.


> 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 ***
>
>
What you want to do at this point in time is to run the process under gdb,
as this will show where malloc detected the error, and then you should get
both the unmanaged stack trace, and if possible the managed one (with the
mono_stack gdb macro)

Miguel.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


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

2015-10-20 Thread Miguel González
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 =  [0]) {
+fixed (CharInfo *ptr =  [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


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list