We have a using statement that crashes the entire dotnet core console app when the Dispose method is called on the Spire.Xls.Core.SpreadSheet.XlsWorkbook class. The method is wrapped in a try/catch, but this ignored as it takes down the entire process.
This is what's written to the event log:
Faulting application name: phoenix.exe, version: 1.0.0.0, time stamp: 0x5ee99cfc
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x00007ff8eb156680
Faulting process id: 0x1b48
Faulting application start time: 0x01d7987b81bac935
Faulting application path: phoenix.exe
Faulting module path: unknown
Report Id: d286ee34-a593-44b8-913b-b520a3f20fc7
Faulting package full name:
Faulting package-relative application ID:
I've created a crash dump file and analysed it with windbg. The crash dump proves the Dispose() method is what's crashing the CLR:
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(369c.3464): Access violation - code c0000005 (first/second chance not available)
For analysis of this file, run !analyze -v
ntdll!NtWaitForMultipleObjects+0x14:
00007ff9`9cc50544 c3 ret
0:002> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************
MethodDesc: 00007ff8ea61d278
Method Name: Spire.Xls.Core.Spreadsheet.XlsWorkbook.Dispose()
Class: 00007ff8ea64a460
MethodTable: 00007ff8ea61d428
mdToken: 000000000600A493
Module: 00007ff8ea554660
IsJitted: yes
Current CodeAddr: 00007ff8ea20b6e0
Version History:
ILCodeVersion: 0000000000000000
ReJIT ID: 0
IL Addr: 0000000000000000
CodeAddr: 00007ff8ea20b6e0 (QuickJitted)
NativeCodeVersion: 0000000000000000
MethodDesc: 00007ff8ea61d278
Method Name: Spire.Xls.Core.Spreadsheet.XlsWorkbook.Dispose()
Class: 00007ff8ea64a460
MethodTable: 00007ff8ea61d428
mdToken: 000000000600A493
Module: 00007ff8ea554660
IsJitted: yes
Current CodeAddr: 00007ff8ea20b6e0
Version History:
ILCodeVersion: 0000000000000000
ReJIT ID: 0
IL Addr: 0000000000000000
CodeAddr: 00007ff8ea20b6e0 (QuickJitted)
NativeCodeVersion: 0000000000000000
Failed to request MethodData, not in JIT code range
Failed to request MethodData, not in JIT code range
CONTEXT: (.ecxr)
rax=00000046beb7e640 rbx=0000000000000000 rcx=000001e7431accb8
rdx=00007ff94775f187 rsi=000001e78530d1c0 rdi=00007ff8ea61d428
rip=00007ff998ed9329 rsp=00000046beb7f330 rbp=00000046beb7f990
r8=000001e79d17b101 r9=00007ff9477d6fd0 r10=000001e7431accb8
r11=00007ff9477d7a09 r12=0000000000000001 r13=0000000000000000
r14=000001e743801d20 r15=0000000000000000
iopl=0 nv up ei pl nz na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
KERNELBASE!RaiseException+0x69:
00007ff9`98ed9329 0f1f440000 nop dword ptr [rax+rax]
Resetting default scope
EXCEPTION_RECORD: (.exr -1)
ExceptionAddress: 00007ff8ea20b700
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 0000000000000000
Attempt to read from address 0000000000000000
PROCESS_NAME: phoenix.exe
READ_ADDRESS: 0000000000000000
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.
EXCEPTION_CODE_STR: c0000005
And here's the thread's stack that blew it up:
0:002> !PrintException /d 000001e7369bd8d0
Exception object: 000001e7369bd8d0
Exception type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
InnerException: <none>
StackTrace (generated):
SP IP Function
00000046BEB7F970 00007FF8EA20B700 Spire_XLS!Spire.Xls.Core.Spreadsheet.XlsWorkbook.Dispose()+0x20
00000046BEB7F9A0 00007FF8EA20B684 Spire_XLS!Spire.Xls.Core.Spreadsheet.XlsObject.Finalize()+0x24
Can you please advise on a way forward with this, as it looks like the Dispose method is using a null reference, however it's taking down the whole CLR app with this native code error:
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.
Kind Regards,
Jason