Handmade Hero»Forums»Code
19 posts
d012 - "stack-based buffer overrun"
Hello guys,

I'm testing my code 43 minutes into the day 12 video.
I have the sound playing for approx 2 sec, and then the program crashes with the following error :

"Access Violation Write Location" and
"Stack cookie instrumentation code detected a stack-based buffer overrun"

VS points to the Game_OutputSound() method in the handmade.cpp file : first time *sampleOut++ = sampleValue;

How do I go about trying to figure out what I did wrong ?

Thanks !

(VS2015 + Win10)
Mārtiņš Možeiko
2568 posts / 2 projects
d012 - "stack-based buffer overrun"
Typically that means you wrote past the end of array that is on stack.
Verify in debugger that length of arrays and iteration count for loops is what you expect. For example, try to set for loop iteration count to 0 and see if crash happens. If it doesn't crash, then count is wrong.