Bug in OleDbConnection (WeakReferenceCache)

G

Guest

Here is a bug that Microsoft should address:

In the System.Data.Common.WeakReferenceCollection.Close(boolean) method, it makes an unconditional check on a System.WeakReference.Target property. It does this to see if it is "alive", so it can null it out. The problem is, if the Target is invalid, the get_Target() method throws an "System.InvalidOperationException: Handle is not initialized" exception.
Either, the get_Target() method should NOT throw exceptions and return null if the handle is invalid OR WeakReferenceCollection.Close(boolean) method should try/catch the querying of the System.WeakReference.Target property.

The bug only appears when the system is under heavy CPU load. It is

The stack trace:
System.InvalidOperationException: Handle is not initialized.
at System.WeakReference.get_Target()
at System.Data.Common.WeakReferenceCollection.Close(Boolean flag)
at System.Data.OleDb.OleDbConnection.CloseReferences(Boolean canceling)
at System.Data.OleDb.OleDbConnection.DisposeManaged()
at System.Data.OleDb.OleDbConnection.Close()
at System.Data.Common.DbDataAdapter.QuietClose(IDbConnection connection, ConnectionState originalState)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
.....

Thoughts, suggestions, validations are welcome.

-Michael Briggs
 
J

jeremy.m.white

I am getting similar errors at random times. Here are three separate
scenarios that I have run into recently. I am unable to determine what
is causing the error. Any thoughts?

1
----------------------------------------------------------------------------------------------------
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.InvalidOperationException: Handle is not initialized.
at System.WeakReference.get_Target()
at System.Data.Index.get_RowFilter()
at System.Data.Index.Equal(Int32[] indexDesc, DataViewRowState
recordStates, IFilter rowFilter)
at System.Data.DataTable.GetIndex(Int32[] indexDesc,
DataViewRowState recordStates, IFilter rowFilter)
at System.Data.DataView.UpdateIndex(Boolean force)
at System.Data.DataView.SetIndex(String newSort, DataViewRowState
newRowStates, DataFilter newRowFilter)
at System.Data.DataView..ctor(DataTable table, Boolean locked)
at System.Data.DataTablePropertyDescriptor.GetValue(Object
component)
at System.Web.UI.DataSourceHelper.GetResolvedDataSource(Object
dataSource, String dataMember)
at System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at Dart.WebUsage.WebMaint.UpdateUserDistribution.BindDistribution()
at Dart.WebUsage.WebMaint.UpdateUserDistribution.Page_Load(Object
sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously


2
----------------------------------------------------------------------------------------------------
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.InvalidOperationException: Handle is not initialized.
at System.Data.DataTable.SetNewRecord(DataRow row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge)
at System.Data.DataRow.SetNewRecord(Int32 record)
at System.Data.DataRow.EndEdit()
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at Dart.WebUsage.BusinessEntity.UserRow.set_UserName(String Value)
in C:\Work\ISALog\BusinessEntity\UserDS.vb:line 380
at Dart.WebUsage.Controller.UserController.UpdateUserInfo(String
userName, String firstName, String lastName, String department, String
subDepartment) in
C:\Work\ISALog\Dart.WebUsage.Controller\UserController.vb:line 104
at Dart.WebUsage.WebMaint.UpdateUser.UpdateInfo() in
c:\inetpub\wwwroot\WebUsageMaint\UpdateUser.aspx.vb:line 102
at Dart.WebUsage.WebMaint.UpdateUser.lnkUpdate_Click(Object sender,
EventArgs e) in
c:\inetpub\wwwroot\WebUsageMaint\UpdateUser.aspx.vb:line 171
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)


3
----------------------------------------------------------------------------------------------------
System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.InvalidOperationException: Handle is not initialized.
at System.WeakReference.get_Target()
at System.Data.DataViewListener.IndexListChanged(Object sender,
ListChangedEventArgs e)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.DataTable.AcceptChanges()
at Dart.FilmCost.FilmBO.PublishFilmInks(FilmInkDataTable filmInks,
String filmCode)
at Dart.FilmCost.FilmController.Publish()
at Dart.FilmCost.FilmController.ByPassWarning()
at Dart.FilmCost.WebUI.InvalidObject.lnkConfirm_Click(Object sender,
EventArgs e)
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top