Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: when accessing 2nd mocked class object (see example) #449

Closed
mohand1993 opened this issue Sep 21, 2017 · 4 comments
Closed

Crash: when accessing 2nd mocked class object (see example) #449

mohand1993 opened this issue Sep 21, 2017 · 4 comments

Comments

@mohand1993
Copy link

The following code block cause the crash below.


var obj = new Mock<Object>().Object;
var stream = new Mock<Stream>().Object;
  • Assertion at dynamic-image.c:209, condition `prev == MONO_HANDLE_RAW (obj)' not met

Stacktrace:

at <0xffffffff>
at (wrapper managed-to-native) System.Reflection.Emit.ModuleBuilder.getToken (System.Reflection.Emit.ModuleBuilder,object,bool) <0x00015>
at System.Reflection.Emit.ModuleBuilder.GetToken (System.Reflection.MemberInfo,bool) [0x00061] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs:793
at System.Reflection.Emit.ModuleBuilderTokenGenerator.GetToken (System.Reflection.MemberInfo,bool) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs:1207
at System.Reflection.Emit.ILGenerator.Emit (System.Reflection.Emit.OpCode,System.Reflection.MethodInfo) [0x0004e] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs:734
at Castle.DynamicProxy.Generators.Emitters.SimpleAST.MethodTokenExpression.Emit (Castle.DynamicProxy.Generators.Emitters.IMemberEmitter,System.Reflection.Emit.ILGenerator) [0x0000c] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.Emitters.SimpleAST.AssignStatement.Emit (Castle.DynamicProxy.Generators.Emitters.IMemberEmitter,System.Reflection.Emit.ILGenerator) [0x00019] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.Emitters.CodeBuilders.AbstractCodeBuilder.Generate (Castle.DynamicProxy.Generators.Emitters.IMemberEmitter,System.Reflection.Emit.ILGenerator) [0x00058] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.Emitters.ConstructorEmitter.Generate () [0x0001e] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.EnsureBuildersAreInAValidState () [0x000c6] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType () [0x00001] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType (string,System.Type[],Castle.DynamicProxy.Generators.INamingScope) [0x0015d] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.ClassProxyGenerator/<>c__DisplayClass1.b__0 (string,Castle.DynamicProxy.Generators.INamingScope) [0x0000e] in <1da8a528a77240358e1afd90a17b1a27>:0
at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType (Castle.DynamicProxy.Generators.CacheKey,System.Func3<string, Castle.DynamicProxy.Generators.INamingScope, System.Type>) [0x00141] in <1da8a528a77240358e1afd90a17b1a27>:0 at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode (System.Type[],Castle.DynamicProxy.ProxyGenerationOptions) [0x00064] in <1da8a528a77240358e1afd90a17b1a27>:0 at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType (System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions) [0x0002c] in <1da8a528a77240358e1afd90a17b1a27>:0 at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType (System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions) [0x00009] in <1da8a528a77240358e1afd90a17b1a27>:0 at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy (System.Type,System.Type[],Castle.DynamicProxy.ProxyGenerationOptions,object[],Castle.DynamicProxy.IInterceptor[]) [0x00064] in <1da8a528a77240358e1afd90a17b1a27>:0 at Moq.Proxy.CastleProxyFactory.CreateProxy (System.Type,Moq.Proxy.ICallInterceptor,System.Type[],object[]) [0x0004a] in <1da8a528a77240358e1afd90a17b1a27>:0 at Moq.Mock1<T_REF>.b__24_0 () [0x00092] in <1da8a528a77240358e1afd90a17b1a27>:0
at Moq.PexProtector.Invoke (System.Action) [0x00001] in <1da8a528a77240358e1afd90a17b1a27>:0
at Moq.Mock1<T_REF>.InitializeInstance () [0x0000c] in <1da8a528a77240358e1afd90a17b1a27>:0 at Moq.Mock1<T_REF>.OnGetObject () [0x00011] in <1da8a528a77240358e1afd90a17b1a27>:0
at Moq.Mock.GetObject () [0x00001] in <1da8a528a77240358e1afd90a17b1a27>:0
at Moq.Mock.get_Object () [0x00001] in <1da8a528a77240358e1afd90a17b1a27>:0
at Moq.Mock`1<T_REF>.get_Object () [0x00001] in <1da8a528a77240358e1afd90a17b1a27>:0

@stakx
Copy link
Contributor

stakx commented Sep 21, 2017

This works fine both on the CLR (.NET), as well as on my installation of Mono (the following being the version information of my installation as dumped by mono --version):

Mono JIT compiler version 5.2.0 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: normal
Notification: Thread + polling
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

What OS and version of Mono are you running your code on?

@stakx
Copy link
Contributor

stakx commented Oct 1, 2017

@mohand1993: Without any more info, it's hard to follow up on this. I suspect this is more of a problem with the Mono runtime than it is with Moq (see above) so perhaps it would be good if you reported that with the Mono team.

I'm closing this for the time being due to a lack of sufficient information. Please post back if you want to follow up on this, we can reopen the issue.

@bartdkmediahuis
Copy link

@stakx : Having the same issue :

Mono JIT compiler version 5.4.0.201 (2017-06/71277e78f6e Thu Sep 21 19:22:55 EDT 2017) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: altstack Notification: kqueue Architecture: amd64 Disabled: none Misc: softdebug LLVM: yes(3.6.0svn-mono-master/8b1520c8aae) GC: sgen (concurrent by default)

@stakx
Copy link
Contributor

stakx commented Oct 11, 2017

@mohand1993, @bartdkmediahuis: Apparently that Mono version (5.4.0.201) is affected by some sort of bug, it's nothing to do with Moq. See #481.

I suggest you use a different version of Mono. (5.2 wasn't affected, AFAIK, and perhaps they've published a fixed version by now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants