[Mono-list] Assertion failures when using Moq on Linux/ARM

Weeble clockworksaint at gmail.com
Fri Feb 4 05:52:52 EST 2011

I'm currently running Mono 2.6.7 on an ARM box (a Sheevaplug) running
Linux. When I try to run unit tests that work on Windows-x86 with
Microsoft's CLR and on Linux-x86 with Mono, they fail often (but not
always) with an assertion:

ERROR:mini-arm.c:2579:handle_thunk: assertion failed: (pdata.found == 1)

  at (wrapper managed-to-native)
(System.Type,object,System.Reflection.MethodInfo,bool) <0xffffffff>
  at System.Delegate.CreateDelegate
(System.Type,object,System.Reflection.MethodInfo,bool) <0x006c0>
  at System.Delegate.CreateDelegate
(System.Type,object,System.Reflection.MethodInfo) <0x0002f>
  at System.Reflection.Emit.DynamicMethod.CreateDelegate
(System.Type,object) <0x0003f>
  at System.Linq.Expressions.EmitContext.CreateDelegate
(System.Runtime.CompilerServices.ExecutionScope) <0x0003f>
  at System.Linq.Expressions.CompilationContext.CreateDelegate
(int,System.Runtime.CompilerServices.ExecutionScope) <0x00043>
  at System.Linq.Expressions.CompilationContext.CreateDelegate () <0x0003f>
  at System.Linq.Expressions.LambdaExpression.Compile () <0x00053>
  at System.Linq.Expressions.Expression`1<object>.Compile () <0x0001b>
  at Moq.Mock.GetInterceptor
(System.Linq.Expressions.Expression,Moq.Mock) <0x00073>
  at Moq.Mock.Verify<object>
  at Moq.Mock`1<object>.Verify

You can see the source of GetInterceptor here:

private static Interceptor GetInterceptor(Expression fluentExpression,
Mock mock)
        var targetExpression = FluentMockVisitor.Accept(fluentExpression, mock);
        var targetLambda =
        var targetObject = targetLambda.Compile()();
        return targetObject.Interceptor;

The expression getting passed in is fairly trivial. My code does this:

iMockListener.Verify(x => x.SetPropInt(1, 1999));

And then I think Verify extracts the object expression from the method
call which I guess is just the identity function?

Looking at mini-arm.c, I think that assertion is saying that it can't
find an appropriate place to create the thunk for a delegate. Is that

1. Is this a bug?
2. If I move to Mono 2.8, am I likely to have any better luck?
3. Does Moq create too many delegates to work properly on ARM? Is this
an inappropriate library to use on an ARM device?
4. Is this problem limited only to doing advanced stuff with Linq
expressions or can it happen simple from creating a lot of delegates?
5. Is it useful for me to try to put together a minimal example to
replicate the problem?

Best regards,


More information about the Mono-list mailing list