How to find source of buffer overflow
-
VC++ Windows XP Hi, I have to maintain a large application which sometimes crashes at the end. The cause is probably a buffer overflow somewhere: From time to time a system error message showed up which said that the code segment had been affected. I would like to find the source of the overflow but couldn't figure out where it could be. It only happens in the release version. I think this is due to the different initialization of debug memory with CD DD and so on. I think it would be easier, when I could run a debug session with heap and stack being initialized in the same way as in the release version. Is there any possibility to get that? Or is there a tool which can show me e.g.
slice of memory on the heap | origin routine | virtual addr begin | virtual addr end |
pFoo bar 0x00002000 0x20000000Thank you Regards Werner
-
VC++ Windows XP Hi, I have to maintain a large application which sometimes crashes at the end. The cause is probably a buffer overflow somewhere: From time to time a system error message showed up which said that the code segment had been affected. I would like to find the source of the overflow but couldn't figure out where it could be. It only happens in the release version. I think this is due to the different initialization of debug memory with CD DD and so on. I think it would be easier, when I could run a debug session with heap and stack being initialized in the same way as in the release version. Is there any possibility to get that? Or is there a tool which can show me e.g.
slice of memory on the heap | origin routine | virtual addr begin | virtual addr end |
pFoo bar 0x00002000 0x20000000Thank you Regards Werner
You could compile your project without optimization (debug) and link it with the debug "pdb" information :) (These are the project settings) Secondly, you could try to restrict the RT reproducing context as possible :)
virtual void BeHappy() = 0;
-
VC++ Windows XP Hi, I have to maintain a large application which sometimes crashes at the end. The cause is probably a buffer overflow somewhere: From time to time a system error message showed up which said that the code segment had been affected. I would like to find the source of the overflow but couldn't figure out where it could be. It only happens in the release version. I think this is due to the different initialization of debug memory with CD DD and so on. I think it would be easier, when I could run a debug session with heap and stack being initialized in the same way as in the release version. Is there any possibility to get that? Or is there a tool which can show me e.g.
slice of memory on the heap | origin routine | virtual addr begin | virtual addr end |
pFoo bar 0x00002000 0x20000000Thank you Regards Werner
Try also to make the following test (may be in a small separate application) :
{
int* pInt = new int[20];
pInt = new int[10];
pInt = new int[30];
pInt = new int[10];
}...an then pass it to your diagnostic tool :)
virtual void BeHappy() = 0;
-
VC++ Windows XP Hi, I have to maintain a large application which sometimes crashes at the end. The cause is probably a buffer overflow somewhere: From time to time a system error message showed up which said that the code segment had been affected. I would like to find the source of the overflow but couldn't figure out where it could be. It only happens in the release version. I think this is due to the different initialization of debug memory with CD DD and so on. I think it would be easier, when I could run a debug session with heap and stack being initialized in the same way as in the release version. Is there any possibility to get that? Or is there a tool which can show me e.g.
slice of memory on the heap | origin routine | virtual addr begin | virtual addr end |
pFoo bar 0x00002000 0x20000000Thank you Regards Werner
See the Newcomer's classic "Surviving the Release Version" :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
VC++ Windows XP Hi, I have to maintain a large application which sometimes crashes at the end. The cause is probably a buffer overflow somewhere: From time to time a system error message showed up which said that the code segment had been affected. I would like to find the source of the overflow but couldn't figure out where it could be. It only happens in the release version. I think this is due to the different initialization of debug memory with CD DD and so on. I think it would be easier, when I could run a debug session with heap and stack being initialized in the same way as in the release version. Is there any possibility to get that? Or is there a tool which can show me e.g.
slice of memory on the heap | origin routine | virtual addr begin | virtual addr end |
pFoo bar 0x00002000 0x20000000Thank you Regards Werner
I prefer WinDbg, very effective in finding the application crashes, handle leaks and all([^])
Величие не Бога может быть недооценена.
-
Try also to make the following test (may be in a small separate application) :
{
int* pInt = new int[20];
pInt = new int[10];
pInt = new int[30];
pInt = new int[10];
}...an then pass it to your diagnostic tool :)
virtual void BeHappy() = 0;
Dear Eugen, the diagnostic tool which I would find very useful would be one, which can show me something like
variable | chunk of heap start | chunk of heap end | length of heap | allocated by (method signature)
pFoo 0x00002000 0x20000000 536862720 heapcrusherbecause I suspect, that the point in the program, where the exception happens is not the one which caused the trouble, but another, which caused a buffer overflow. Sometimes the app crashed at the end and signaled a segment fault. I also tried to debug the app as release version as you suggested but couldn't find out, why it crashed at the point, where it did. Do you know any which can do that? PS is it actually possible to see variable values in the debugger when I debug the release version? I thought there is no way. Thank you regards Werner
-
I prefer WinDbg, very effective in finding the application crashes, handle leaks and all([^])
Величие не Бога может быть недооценена.
-
Dear Eugen, the diagnostic tool which I would find very useful would be one, which can show me something like
variable | chunk of heap start | chunk of heap end | length of heap | allocated by (method signature)
pFoo 0x00002000 0x20000000 536862720 heapcrusherbecause I suspect, that the point in the program, where the exception happens is not the one which caused the trouble, but another, which caused a buffer overflow. Sometimes the app crashed at the end and signaled a segment fault. I also tried to debug the app as release version as you suggested but couldn't find out, why it crashed at the point, where it did. Do you know any which can do that? PS is it actually possible to see variable values in the debugger when I debug the release version? I thought there is no way. Thank you regards Werner
Hallo Werner, 0. Yes, you can see any value at the debugging of your release project now :) 1. The message of the tool is different now :) 2. When you say "crashes at the end" - please try the following code by your tool:
{
int* pInt = new int[30];
delete pInt;
for (int i = 0; i < 100; i++) {
int* pChar = new char[1024];
delete pChar;
delete pChar;
}
delete pInt;
}3. Is there a way to reduce the application and reproduce the effect ? :)
virtual void BeHappy() = 0;