What could cause the return function to fail? C ++

So, I debugged this error for hours. I am writing a program using Ogre3d that is relevant only because it does not load characters, so it does not allow me to trace the trace, which further complicates the detection of the accident site. So, write before I call a specific function, I will print β€œRun”, then I will call the function and right after I type β€œStop”. Throughout the function, I type the letters AF, where F is printed right before the function returns (one line above the last "}"). It’s strange when a crash occurs, after printing β€œF”, but there is no β€œstop.” Does this mean that the crash is happening somewhere? The only thing I can think of is something is wrong while freeing up some memory, highlighted during function.I have never had anything like it,I will continue to verify that this does not happen correctly, where I think.

+3
source share
2 answers

In most cases, when something strange and incomprehensible happens, it is because of something else.

You may have dangling pointers in your code (even away from this function) pointing to some random memory locations.

Perhaps you used such a dangling pointer, and this could lead to overwriting some memory cells that you need. The result of this is that you changed the behavior of your program by changing some variable defined elsewhere, some constants, or even some code!

I suggest you debug your application using some tool that can check and report memory access errors, like Valgrind .


, , , ​​ , , .

+4

, , , , , - . , , , , ..

, . , "" , stdout. , , .

+2

Source: https://habr.com/ru/post/1785600/


All Articles