KitKat
KitKat

Reputation: 131

What could prevent a stack unwinding process in C++?

I'm not sure how to approach it. The question was given after a lecture about Exceptions so I assume it has something to do with it.

Upvotes: 1

Views: 440

Answers (2)

Olivier Poulin
Olivier Poulin

Reputation: 1796

When a scope is exited, stack unwinding starts, which means the compiler inserts calls to destructors of automatic variables, as explained in this answer.

For this process to be prevented, you would need a sudden exiting of the process, which could be loss of power, force quitting the process through the command line, etc.

Upvotes: 1

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

Default signal handlers, or calls to abort() and exit() could prevent stack unvinding.

And there's many more situations, like pointed out in mah's comment.

Especially any mechanism bypassing the c++ exception model will do so. Even threads have a model to do proper stack unwinding, with having them propagated to their parents (if they weren't detached).

Upvotes: 1

Related Questions