Skip to main content
gamedev.net
🔒 Locked

Memory corruption help

Started by Butabee 3 replies 950+ views
Original Post
Butabee
Butabee
So while I'm busy making my game I've come across what looks like memory corruption but I'm not sure what's causing it.

It only happens in one function, and it's right when it is entered.

local variables don't have their correct value.

The memory is fine before and after the function is called but inside it, the memory looks messed up.

This only happens in the release version too.


When the game crashed before it pointed me to something about pfn encodepointer or something, and gave a bad_alloc message.


The function is fairly large, so I'm wondering if maybe it's too big for the stack? idk.
Butabee
Butabee
I don't know if it's actually memory corruption, I think it may just be the debugger that is having errors.

I think this because the debugger is saying that a loop variable is a huge number but I put a break point after the loop and it doesn't loop a lot.
Hodgman
Hodgman
Quote:
Original post by Butabee
This only happens in the release version ... I don't know if it's actually memory corruption, I think it may just be the debugger that is having errors.
Yeah, the debugger usually won't show correct values for optimised binaries (release mode). You can go into your project properties and turn off optimisation to try and make release-mode debuggable.
Zipster
Zipster
You can always drop down into the disassembly and observe the underlying registers directly. As long as you're somewhat familiar with loop constructs in assembly it shouldn't be too difficult to follow.
cache_hit
cache_hit
I second Hodgman's response. Your program is fine, but you can't debug optimized binaries. printf the value and you'll see that it's fine.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.