开发者

what does "Attempt to execute non-executable address" mean?

开发者 https://www.devze.com 2023-03-24 10:47 出处:网络
I see an access violation error in my c++ application. On attaching windbg to the process when the violation happens and using !analyze, I found the access violation was due to an attempt to execute a

I see an access violation error in my c++ application. On attaching windbg to the process when the violation happens and using !analyze, I found the access violation was due to an attempt to execute a non executable address. I know the address that is being executed that is causing this. What could lead to this error? What possible error in code could 开发者_Go百科make this to happen? How do I effectively debug that?


The two common reasons in C++ for this error are 1) Using a virtual function of an uninitialized/deleted object and 2) using an uninitialized function pointer. In either case, you're effectively branching to a random address. Since most memory isn't marked as executable, you will likely be stopped by an "attempt to execute non-executable address"


This is not an error in code. This means you are trying to execute non-code means memory which belongs to .data store such as variable declaration or anything other than code. This can be caused due to an invalid pointer.


Data Execution Prevention is described here: http://msdn.microsoft.com/en-us/library/aa366553(v=vs.85).aspx. Possible way to get this error is to override function return address on the stack. So, you need to check the code which is executed just before this access violation.


There's no silver bullet for debugging this. As others have said, somehow a non-executable address was run.

Your goal is to find out where the invalid address came from. Your best bet is to start with the stack trace of the faulting thread. From there you can see if this is a vtable pointer, a pointer to a callback function, or something else. It should give you enough info to know where in code to look poke around.

If you can figure out how that value is passed around, you should be able to set some breakpoints and follow the value until it becomes invalid. Binary search is nice systematic way to root cause issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消