NullReferenceException in CachingCommand.Dispose(Boolean)
icnocop opened this issue · comments
Hi.
A NullReferenceException
may be thrown in EFCache.CachingCommand.Dispose(Boolean)
if an an OutOfMemoryException is previously thrown (in EFCache.CachingCommandDefinition.CreateCommand()
for example).
This caused my application to crash.
First exception:
System.OutOfMemoryException
at System.Object.MemberwiseClone()
at System.Array.Clone()
at System.Data.SqlClient.SqlParameter..ctor(SqlParameter source)
at System.Data.SqlClient.SqlParameter.System.ICloneable.Clone()
at System.Data.Entity.SqlServer.SqlProviderServices.CloneDbCommand(DbCommand fromDbCommand)
at System.Data.Entity.Core.Common.DbCommandDefinition.CreateCommand()
at EFCache.CachingCommandDefinition.CreateCommand()
at System.Data.Entity.Core.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(Dictionary`2 identifierValues)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at MyApplication.MyCodeFirstDatabase.Model.MyDatabaseContext.SaveChanges()
Second exception:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at EFCache.CachingCommand.Dispose(Boolean)
at System.ComponentModel.Component.Finalize()
Thank you.
Nice stress testing. I would love to know which part is actually null 😀
Seems that the object was created but the _command
was not yet initialized when the OutOfMemory exception was thrown.