One of the things I've been working during these past few days in my spare time is rewriting the build system for a project I've been involved in. Though usually we just build directly in Visual Studio 2005 during development, we also need to target .NET 1.1 and Mono was always an idea.

What the project was originally doing was building against .NET 1.1 using MSBee. While this worked, it meant one more thing to install, and unfortunately, MSBee also has a few cumbersome requirements, particularly given that our build was pretty simple (meaning we didn't need much more than what the bare framework includes to build).

For mono, someone had created a long while ago a MonoDevelop solution and project files, but no one mantained them and were completely out of date. Fixing that would've been pretty cumbersome by hand.

So I really wanted to have something a bit more automated and that would allow us to build against any of the three targets easily. I particularly was interested in ensuring I could quickly build the project for all three targets before committing anything, to avoid breaking the build.

I ended up, of course, turning to trusty NAnt. In a couple of hours I had a decent set of buildfiles created that would require little maintainance and that could be used to build against all three targets. Add a couple of shell scripts on top of that to build for specific targets and I was done.

So far, I'm pretty happy with the results. I can build on my windows machine even against mono and it took very little effort to make it work on Linux as well (mostly just ensuring paths were in the correct case). However, unit tests, built using NUnit, have been a bit of a problem.

Our tests run just fine in both .NET 2.0 and .NET 1.1 under Windows (both using the standalone NUnit GUI as well as under NAnt). However, they fail miserably under Mono.

Here's what I get running the tests on Windows using Mono 1.2.4 with NAnt 0.85:


Stacktrace:
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[]) <0x00004>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[]) <0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x00099>
at System.Reflection.MonoProperty.GetValue (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x00067>
at System.Reflection.PropertyInfo.GetValue (object,object[]) <0x0001a>
at NUnit.Core.TestFramework.GetAssertCount () <0x00073>
at NUnit.Core.TestFixture.DoFixtureSetUp (NUnit.Core.TestResult) <0x00259>
at NUnit.Core.TestSuite.DoOneTimeSetUp (NUnit.Core.TestResult) <0x00137>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0012a>
at NUnit.Core.TestSuite.RunAllTests (NUnit.Core.TestSuiteResult,NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0023f>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0013d>
at NUnit.Core.TestSuite.RunAllTests (NUnit.Core.TestSuiteResult,NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0023f>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0013d>
at NUnit.Core.TestSuite.RunAllTests (NUnit.Core.TestSuiteResult,NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0023f>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0013d>
at NUnit.Core.TestSuite.RunAllTests (NUnit.Core.TestSuiteResult,NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0023f>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0013d>
at NUnit.Core.TestSuite.RunAllTests (NUnit.Core.TestSuiteResult,NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0023f>
at NUnit.Core.TestSuite.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x0013d>
at NUnit.Core.TestAssembly.Run (NUnit.Core.EventListener,NUnit.Core.IFilter) <0x00054>
at NUnit.Core.SimpleTestRunner.Run (NUnit.Core.EventListener,NUnit.Core.Test[]) <0x0013d>
at NUnit.Core.SimpleTestRunner.Run (NUnit.Core.EventListener,string[]) <0x0008b>
at NUnit.Core.TestRunnerThread.TestRunnerThreadProc () <0x00029>
at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void () <0xffffffff>
at (wrapper runtime-invoke) System.Object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Under linux, using mono 1.2.3.1 with NAnt 0,85 (or even running Nunit 2.4.1 standalone), here's what I get:


Native stacktrace:

/usr/bin/cli [0x818f7de]
/usr/bin/cli [0x8171be4]
[0xffffe440]
/usr/lib/libglib-2.0.so.0 [0xb7e77e9e]
/usr/bin/cli [0x80d24b6]
/usr/bin/cli [0x8171a51]
/usr/bin/cli(mono_runtime_invoke+0x27) [0x80b038f]
/usr/bin/cli(mono_runtime_delegate_invoke+0x62) [0x80b0617]
/usr/bin/cli(mono_runtime_run_main+0x304) [0x80b4f0a]
/usr/bin/cli(mono_jit_exec+0xbd) [0x805a55b]
/usr/bin/cli [0x805a638]
/usr/bin/cli(mono_main+0x1666) [0x805be3c]
/usr/bin/cli [0x80596c6]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc) [0xb7ce9ebc]
/usr/bin/cli [0x8059621]

Debug info from gdb:

(no debugging symbols found)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1211291936 (LWP 22053)]
[New Thread -1226232944 (LWP 22057)]
[New Thread -1225180272 (LWP 22056)]
[New Thread -1220764784 (LWP 22055)]
[New Thread -1214997616 (LWP 22054)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
0xffffe410 in __kernel_vsyscall ()
5 Thread -1214997616 (LWP 22054) 0xffffe410 in __kernel_vsyscall ()
4 Thread -1220764784 (LWP 22055) 0xffffe410 in __kernel_vsyscall ()
3 Thread -1225180272 (LWP 22056) 0xffffe410 in __kernel_vsyscall ()
2 Thread -1226232944 (LWP 22057) 0xffffe410 in __kernel_vsyscall ()
1 Thread -1211291936 (LWP 22053) 0xffffe410 in __kernel_vsyscall ()

Thread 5 (Thread -1214997616 (LWP 22054)):
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7e48986 in ?? () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x0811700b in ?? ()
#3 0xb794939c in ?? ()
#4 0x00000000 in ?? ()

Thread 4 (Thread -1220764784 (LWP 22055)):
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7e455c6 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib/tls/i686/cmov/libpthread.so.0
#2 0x0811c14a in ?? ()
#3 0xb78b31dc in ?? ()
#4 0xb78b31c4 in ?? ()
#5 0xb73c9178 in ?? ()
#6 0x00000000 in ?? ()

Thread 3 (Thread -1225180272 (LWP 22056)):
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7d9405b in read () from /lib/tls/i686/cmov/libc.so.6
#2 0xb6f96291 in ?? ()
#3 0x00000009 in ?? ()
#4 0x00129010 in ?? ()
#5 0x00001000 in ?? ()
#6 0x00f93204 in ?? ()
#7 0x00129010 in ?? ()
#8 0x08527400 in ?? ()
#9 0x00001000 in ?? ()
#10 0x00000000 in ?? ()

Thread 2 (Thread -1226232944 (LWP 22057)):
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7e4584c in pthread_cond_timedwait@@GLIBC_2.3.2 ()
from /lib/tls/i686/cmov/libpthread.so.0
#2 0x0811c1c7 in ?? ()
#3 0xb78b34d0 in ?? ()
#4 0xb78b34b8 in ?? ()
#5 0xb6e9204c in ?? ()
#6 0x00000000 in ?? ()

Thread 1 (Threa
d -1211291936 (LWP 22053)):
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7d63f59 in fork () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7e4a7e4 in fork () from /lib/tls/i686/cmov/libpthread.so.0
#3 0xb7eaf7d9 in ?? () from /usr/lib/libglib-2.0.so.0
#4 0x00000010 in ?? ()
#5 0xb7e12128 in ?? () from /lib/tls/i686/cmov/libc.so.6
#6 0xb7e12150 in ?? () from /lib/tls/i686/cmov/libc.so.6
#7 0x00000020 in ?? ()
#8 0x00000000 in ?? ()
#0 0xffffe410 in __kernel_vsyscall ()

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted (core dumped)

I'm not quite sure that the two errors are related (I'm thinking I'm hitting different issues in both platforms), but even so I've been unable to find much useful info on what might be causing them. Anyone has any ideas?

Technorati tags: , , ,


Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.