Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Buffer overrun

Author
Message
frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 15th Jan 2007 23:31
I'm running out of ideas how to fix this... I have this error:


Quote: "
A buffer overrun has occurred in ProjectXO.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

"


When I try to terminate my program and this is the line that causes it:




any clues as to how to solve this problem?
frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 15th Jan 2007 23:35
By the way, intfile is declared as


char intfile[100];
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 15th Jan 2007 23:52
What is interrupt, because it should be declared as an integer otherwise the formatting string will probably b0rk. Also, are you definately sure it's that line, and maybe not something before it?

Paul.

frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 16th Jan 2007 00:33
interrupt is definitely an integer and it seems like anything that deals with my char buffer intfile causes that problem. It seems to be like this. If I initalize intfile through char intfile[100] = {""}, char intfile[100] = {"\0"}, or char intfile[100] = "\0", even if I comment that line above and the rest that deals with intfile, I get that buffer overrun error when terminating my program. But if I just declare the variable infile through char intfile[100]; and comment the line above and the rest of the codes that deals with intfile, everything terminates just fine.

And in the debugger, it stops at file dbghook.c at line 65 with the error mentioned above. I set a breakpoint when I'm about to exit the program, and tracked the value of my variable intfile. If I don't initialize my variable, and uncomment the line above (sprintf ...), my variable has some negative value (-52 to be exact) and when I'm about to exit my program, dbhook.c seems to be activated and does something that the program stops there and cause the error I mentioned above to appear.

I hope I stated the case clearly, so any information would be greatly appreciated.
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 16th Jan 2007 01:06
Well, I'm not really sure why you're getting such a volatile error, because it sounds to me like the stack is getting b0rked, and this can happen in a call before your function that declares the char array. Normally, specially if the code looks sound and nothing is being done to the string array, that a stack error can occur because of something that happens in the previous function in the call stack.

Also, can you make sure that you disable any optimization compiler flags, just to be sure that the compiler isn't trying something with duplicate strings?

Other than that, unless you can provide a full sample or a cut down sample that replicates the error, I can't suggest anything else.

Paul.

frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 16th Jan 2007 01:26
I understand, after few research over the internet, i found out that in MSVC++ 2005, for security purposes, a buffer exception handling is set to enable as default and through Dr. Watson method, that buffer overrun error is activated when a possible buffer overrun is detected. At least this is how I understood it. A bad solution for this is I set that check to disable. This is because I made sure that my buffer is big enough. There are other solutions out there, but I'll study it when I have the time. Thanks for your help.
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 16th Jan 2007 01:32
Ok, well, I was aware that MSVC 05 allows you to use the deprecated runtime functions for backward compatability, I believe it's the _CRT_SECURE_NO_DEPRECATE flag that allows you to use the older string and memory functions etc.

Maybe defining that in your preprocessor project settings will resolve problems. As said, this is for deprecated functions which did exhibit potential security and memory leakage.

Paul.

frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 16th Jan 2007 02:02
as a quick note though, I even if I try using the more secured functions such as strcpy_s and strcat_s and still I got those errors. As a result, my program exits quicker.

Login to post a reply

Server time is: 2024-06-26 09:29:59
Your offset time is: 2024-06-26 09:29:59