CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

Access violation for calls to a extended, cloned, vtable

Open hermann-noll opened this issue 4 years ago • 1 comments

Brief Description

Although not the entire chain of events is clear to me, it can occur that a vtable is cloned although the specific class is not known. When the specific class extended said vtable the pointers to these extended methods are not cloned and trying to call them results in a crash.

I have replicated this bug in your "VTables" test suite and have attached the patch for the new test to this issue. Noteworthy might be that adding a similar pattern to the existing *ClassVirtual classes did not produce the bug for me as the create method would not result in cloning the vtables, so it might be related to pure base classes?

0001-Add-test-for-extended-vtable.patch.txt

OS: Windows 10

Used settings

Target: MSVC

Other settings

Stack trace or incompilable generated code
An unhandled exception of type 'System.AccessViolationException' occurred in VTables.CSharp.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

 	[External Code]	
>	VTables.CSharp.dll!VTables.PureBaseInternal.RetInt() Line 1407	C#
 	VTables.Tests.CSharp.dll!VTablesTests.TestExtendedVirtualTable() Line 115	C#
 	[External Code]	

hermann-noll avatar Aug 26 '21 13:08 hermann-noll

@hermann-noll Thank you very much for the test case, this will really help in tracking this down.

Since this seems like a complicated issue and will surely take a big chunk of time to track down and fix, would your company be willing to sponsor a bug fix via our priority support program?

tritao avatar Aug 26 '21 14:08 tritao