Does an access violation exception happen before or after the offending memory is written?

0

I am seeing some access violations in a C# app which call a c++ dll (cdecl calling convention)

On the stack trace dump I am seeing some bad memory locations:

2aabe80c 00020000 someCdll!somefunction(

short * X_data = 0x00000001,

int * X_sizes = 0x00030002,

short * Y_data = 0x0000002b,

int * Y_sizes = 0x0e7115e8

short * T_data = 0x00000000,

struct someStruct * some_data)+0x268

and getting an access violation exception.

Short * X_data = 0x00000001 looks invalid.

Is it possible that this function changed this and then caused the access violation, or did something else make the change and this function tries to write but gets the access violation before it actually changes the memory?

Or is windbg just giving me bogus data.

Edit* This was caused by a classic buffer overflow in unmanaged code. An array pointer was loaded into a register and then a loop took care of the rest overwriting all of my stack variables, which made it look like the code was in a different state than it was when it crashed.

Thanks,

Jason

interop
access-violation
asked on Stack Overflow Mar 14, 2012 by Jason Hernandez • edited Apr 18, 2012 by Jason Hernandez

1 Answer

0

This was caused by a classic buffer overflow in unmanaged code. An array pointer was loaded into a register and then a loop took care of the rest overwriting all of my stack variables, which made it look like the code was in a different state than it was when it crashed.

answered on Stack Overflow Dec 17, 2014 by Jason Hernandez

User contributions licensed under CC BY-SA 3.0