Stack overflow in c++ with vc++ 2010 [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have met a stack overflow in a program compiled using vc++ 2010. I open a debugger and attached it to the process.
Then I force the program to continue after the stack overflow error, every time there would be an access violation error.
My question is: is the access violation error caused by the stack overflow?

Yes. In Windows, stack overflow is detected by having an unreadable page of memory past the end of the stack. The first fault in this page raises a stack overflow exception. The next one raises an access violation.
But, to get to the core of the problem: don't do that. Stack overflows are not recoverable. Once you've had a stack overflow, your program is in an indeterminate state and you should just let it die.

Related

Unable to create CloudFormation Stacks [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Why is this error coming up:
Confirming Stack pre-requisites Stack dependency missing - StandardTopics Stack does not exist!
The error message is saying that the stack imports information from another stack (called StandardTopics). Therefore, it needs the StandardTopics stack to exist before this new stack can be built.
Look for Fn::ImportValue references in the stack you are trying to deploy. It will contain references to StandardTopics.

Why aren't we given more information about Segmentation Fault during runtime? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Whenever I get a Segmentation Fault error, I know that somewhere I am accessing memory that "does not belong to me".
In some nonobvious cases, I have to rely on debugging tools such as a profiler (Valgrind for example).
Unfortunately, during runtime, I only get the following error message:
Segmentation Fault
And nothing else. My question is:
Why doesn't the program give more info about the error during runtime?
Ps: This is not a question on why segmentation fault errors happen: I understand why.
No you can't, because segfaults are not reported by your program, but by your operating system receiving a trap at the CPU level (which is kind of an exception). At this point, the CPU deems your program unrecoverable and tells the operating system to stop it. Your program cannot do anything but shutdown, because the CPU gave that order.

c++ bad_alloc, but it disappear in gdb [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a big project, compiles fine, but sometimes when I run in terminal(sometimes not)
./run
it gives bad_alloc exception, so i think it might be helpful to backtrace using gdb, so I do
gdb ./run
run
and it weirdly exit normally, nothing wrong shows up, even though I tried a lot of times.
Has someone met similar issues before?
See this answer for what may be different "inside" vs. "outside" of GDB, and what to do about it.
If you can enable core dumps (ulimit -c unlimited), that should give you another way to get the stack trace.
In my experience, most bad_allocs result from one of two root causes:
Uninitialized size:
int size;
if (something) {
// assign to size here
}
std::vector v(size); // Oops: size may be unintialized.
Arithmetic underflow:
std::vector v(other_vector.size() - 20);
Here, if other_vector.size() < 20, you'll get humongous value.

Basic example from chaiscript.com throws an exception at runtime [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I added the include directory of chaiscript to my Projects Additional Dependencies and compiled this example successfully.
If I execute it though, it throws this exception:
Unhandled exception at 0x753D5B68 in CHAISCRIPT_TEST.exe: Microsoft C++ exception: chaiscript::exception::load_module_error at memory location 0x0103F0D8.
After further testing around chaiscript seems to complain about not finding the module chaiscript_stdlib-5.8.0
How do I fix that?
Found the solution. The std_lib module has to be initialized the way the example shows.

C++: ReadProcessMemory() causes crashes [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
ReadProcessMemory() seems to crash my program, when it reads undefined(?) memory.
Well my question is, how can I check if the address is undefined or whatever before I use ReadProcessMemory to avaoid crashes?
The errormessage btw:
Unhandled exception at 0x00ce1c70 in Program.exe: 0xC0000005:
Access violation writing location 0x00e3f000.
The crash is not coming because you are reading invalid / undefined memory, it is coming because you passed an invalid buffer into ReadProcessMemory. Note that the the error message says violation writing, not reading.
You need to make sure the buffer you are passing is appropriately sized for the data amount that you are requesting. If you post the code used to call the method we may be able to help spot the error