How to detect possible / potential stack overflow problems in a c / c++ program?

前端 未结 9 1875
滥情空心
滥情空心 2020-12-04 21:55

Is there a standard way to see how much stack space your app has and what the highest watermark for stack usage is during a run?

Also in the dreaded case of actual o

9条回答
  •  天涯浪人
    2020-12-04 22:38

    I would suggest you to use alternate-signal-stack if you are on linux.

    1. In this case all the signal will be handled over alternate stack.
    2. In case stack overflow occurs, system generates a SEGV signal, this can be handled over alternate stack.
    3. If you do not use it ... then you may not be able to handle the signal, and your program may crash without any handling/erro-reporting.

提交回复
热议问题