Couchbase.Lite.Query.QueryBuilder crashes the application


#1

When we run the following code, it often crashes our application. We get

System.AccessViolationException: ‘Attempted to read or write protected memory. This is often an indication that other memory is corrupt.’

We use Couchbase.Lite 2.0.3 nuget package. This mostly happens when we run our .net application as a windows service

Code snippet:

IQuery searchQuery;
searchQuery = QueryBuilder.Select(SelectResult.All()).From(DataSource.Database(database)).Where(Function.Lower(Expression.Property(“type”)).EqualTo(Expression.String(type.ToLowerInvariant())));
try
{
// Run the query
var result = searchQuery.Execute().ToList();
var documents = result.Select(x => x.GetDictionary(0) as object).ToList();
return documents;
}
finally
{
searchQuery.Dispose();
}

Error Description in Event Log:

The process was terminated due to an internal error in the .NET Runtime at IP 000007FED161E9EB (000007FED1490000) with exit code c0000005.


#2

Fixed the issue by removing searchQuery.Dispose(); from the code.


#3

That by itself is not a fix, so I’d be interested in a reproduction case if you have it. If you do, then please file an issue on the repo. My guess would be that trying to access the contents inside of “documents” after the dispose is causing the issue but I’m not sure.


#4

Yeah, we were trying to access the contents inside of “documents” after the dispose. Now after removing the dispose() function from our code everything is working perfect. Thanks a lot Jim