A heap has been corrupted - SqlCeCommand.Dispose - SQL CE 4 SP1 (4.0.8876.1) - by Math

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 869627 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 5/8/2014 9:04:09 AM
Access Restriction Public

Description

We are having an intermittent application crash when using SQL CE 4 SP1 (4.0.8876.1), which happen every 1-2 days.

The crash is: Unhandled exception at 0x0000000077714102 (ntdll.dll) in WERBA8A.tmp.mdmp: 0xC0000374: A heap has been corrupted (parameters: 0x000000007778B4B0).

The error happen when doing a call to SqlCeResultSet.Close() (code sample bellow). The crash occur very infrequently, maybe once in several tens of thousands calls. When the error occur the whole application crashes (windows service). 

Multiple queries are executed concurrently.

The stack trace is:

 	ntdll.dll!RtlReportCriticalFailure\u001e()
 	ntdll.dll!RtlpReportHeapFailure\u001e()
 	ntdll.dll!RtlpHeapHandleError\u001e()
 	ntdll.dll!RtlpLogHeapFailure\u001e()
 	ntdll.dll!RtlpAnalyzeHeapFailure\u001e()
 	ntdll.dll!RtlpFreeHeap\u001e()
 	ntdll.dll!RtlFreeHeap\u001e()
 	kernel32.dll!HeapFree\u001e()
 	sqlceqp40.dll!operator delete(void *)
 	sqlceqp40.dll!QPCommandEnv::~QPCommandEnv(void)
 	sqlceqp40.dll!QPCommandEnv::`vector deleting destructor'(unsigned int)
 	sqlceqp40.dll!CommandEnvWrapper::Release(void)
 	sqlceqp40.dll!QPCommand::Release(void)
 	sqlceme40.dll!ME_SafeRelease(struct IUnknown * *)
 	[Managed to Native Transition]	
 	System.Data.SqlServerCe.dll!System.Data.SqlServerCe.SqlCeCommand.ReleaseNativeInterfaces()
 	System.Data.SqlServerCe.dll!System.Data.SqlServerCe.SqlCeCommand.Dispose(bool disposing)
 	System.dll!System.ComponentModel.Component.Dispose()
        [--Call to sqlCeResultSet.Close()--]


NOTE. We have a mini dump and an heap dump if required.

UPDATE 2014-05-15: 
The crash does not only occur when calling Dispose() but also when calling ExecuteResultSet. The crash only occur when sharing the same connection between multiple commands and executing command simultaneously.

I added a small project which can replicate the problem. (see attachement). I also updated the "Steps to Reproduce" section and added a workaround.
Sign in to post a comment.