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

IL bug on Mono with 3.0.0-beta2 #351

Closed
MariusVolkhart opened this issue Nov 27, 2016 · 3 comments
Closed

IL bug on Mono with 3.0.0-beta2 #351

MariusVolkhart opened this issue Nov 27, 2016 · 3 comments
Labels

Comments

@MariusVolkhart
Copy link

When performing a FindOne query on a non-empty LiteCollection<BsonDocument> using the Mono runtime, a IL error occurs.

Steps to reproduce

  1. Insert a new BsonDocument into a LiteCollection<BsonDocument>
  2. Call the FindOne method on this collection. The returned value does not need to be used.

Expected behavior

I expect to obtain a BsonDocument matching the query parameters I provide

Observed behavior

Unhandled Exception:
System.InvalidProgramException: Invalid IL code in (wrapper dynamic-method) object:lambda_method (System.Runtime.CompilerServices.Closure,object): IL_0006: callvirt  0x00000003


  at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x00357] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType, System.Object target) [0x0001d] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Linq.Expressions.Compiler.LambdaCompiler.CreateDelegate () [0x00022] in <63992662b765477a898ef49cdcc99ee2>:0 
  at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x0001d] in <63992662b765477a898ef49cdcc99ee2>:0 
  at System.Linq.Expressions.Expression`1[TDelegate].Compile () [0x00000] in <63992662b765477a898ef49cdcc99ee2>:0 
  at LiteDB.Reflection.CreateGenericGetter (System.Type type, System.Reflection.MemberInfo memberInfo) [0x00053] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.BsonMapper.BuildEntityMapper (System.Type type) [0x00104] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.BsonMapper.GetEntityMapper (System.Type type) [0x0002d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.LiteCollection`1[T].EnsureIndex (LiteDB.IndexNotFoundException ex) [0x0000d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.LiteCollection`1+<Find>d__17[T].MoveNext () [0x00093] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0003e] in <63992662b765477a898ef49cdcc99ee2>:0 
  at LiteDB.LiteCollection`1[T].FindOne (LiteDB.Query query) [0x0000d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at ConsoleApplication.Program.Main (System.String[] args) [0x00055] in <40af54cb23eb4b8b9b2b84598012a334>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in (wrapper dynamic-method) object:lambda_method (System.Runtime.CompilerServices.Closure,object): IL_0006: callvirt  0x00000003


  at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x00357] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType, System.Object target) [0x0001d] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Linq.Expressions.Compiler.LambdaCompiler.CreateDelegate () [0x00022] in <63992662b765477a898ef49cdcc99ee2>:0 
  at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x0001d] in <63992662b765477a898ef49cdcc99ee2>:0 
  at System.Linq.Expressions.Expression`1[TDelegate].Compile () [0x00000] in <63992662b765477a898ef49cdcc99ee2>:0 
  at LiteDB.Reflection.CreateGenericGetter (System.Type type, System.Reflection.MemberInfo memberInfo) [0x00053] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.BsonMapper.BuildEntityMapper (System.Type type) [0x00104] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.BsonMapper.GetEntityMapper (System.Type type) [0x0002d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.LiteCollection`1[T].EnsureIndex (LiteDB.IndexNotFoundException ex) [0x0000d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at LiteDB.LiteCollection`1+<Find>d__17[T].MoveNext () [0x00093] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0003e] in <63992662b765477a898ef49cdcc99ee2>:0 
  at LiteDB.LiteCollection`1[T].FindOne (LiteDB.Query query) [0x0000d] in <cf7d51444a0a4bc5ad81388232b575c4>:0 
  at ConsoleApplication.Program.Main (System.String[] args) [0x00055] in <40af54cb23eb4b8b9b2b84598012a334>:0

Environment

Mono version: 4.6.1.5
OSX 10.11.6 "El Capitan"

Additional information

This bug is not observed on a Windows 10 machine with CLR v4.0.30319.

@MariusVolkhart
Copy link
Author

A minimal program to replicate the issue is available at https://github.com/MariusVolkhart/LiteDbIssue351Sample

@mbdavid
Copy link
Owner

mbdavid commented Nov 27, 2016

I guess the problem is when LiteDB try auto create index in Name field when using BsonDocument. Try use EnsureIndex before FindOne. I will fix it

@mbdavid mbdavid added the bug label Nov 27, 2016
mbdavid added a commit that referenced this issue Nov 27, 2016
@mbdavid
Copy link
Owner

mbdavid commented Dec 6, 2016

If problem persist, please re-open issue

@mbdavid mbdavid closed this as completed Dec 6, 2016
github-actions bot pushed a commit to Reddevildragg-UPM-Forks/LiteDB that referenced this issue Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants