Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Aug 24, 2021 4:39 am

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

jason.chase@comtrac.com.au
 
Posts: 3
Joined: Fri Mar 22, 2019 4:47 am

Tue Aug 24, 2021 9:04 am

Hello,

Thanks for your inquiry.

Please try the following.
1. If you are using an older version, we recommend you upgrade to the latest version (the latest version is Spire.Office Platinum(Hotfix) Version:6.8.2) and try it again.
2. Please try to register "Microsoft.mshtml.dll" to GAC like the following commands. And try it again after registering "Microsoft.mshtml.dll".
Code: Select all
gacutil -i E:\Microsoft.mshtml.dll


If the issue still occurs, to help us reproduce your issue and solve it, please provide your input file, your complete code, your project target framework (e.g. .NET Framework 4.5) and your OS information (e.g. Windows7, 64bit). Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 01, 2021 10:21 am

Hello,

Greetings from E-iceblue!
Has your issue been resolved? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Sun Sep 12, 2021 4:50 am

Hello, v6.8.2. has corrected the issue, thank you.

jason.chase@comtrac.com.au
 
Posts: 3
Joined: Fri Mar 22, 2019 4:47 am

Mon Sep 13, 2021 1:18 am

Okay, thanks for your feedback.
If there are any other issues related to our products, just feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.XLS