What does the following runtime error mean: “terminate called without an active exception\n Aborted”

后端 未结 5 1381
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 07:15

The bug disturbed me about two days: when running the code I have a runtime error of \"terminate called without an active exception\\n Aborted\",why?

I try to locate the

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-15 07:24

    The "terminate without an active exception" message is a hint that, at some point in your program, exception handling got broken.

    The memory allocation is probably the primary cause, but probably not the error site. The large allocation will throw a std::bad_alloc exception, and this exception is incorrectly handled somewhere.

    To validate the theory, insert a line like

     throw std::logic_error("Foo");
    

    above the allocation, this should trigger the bug as well.

    I've encountered two common causes for this:

    • Multithreaded mingw programs compiled without the right flags
    • A destructor that was called as part of the stack unwinding process has thrown an exception

    You should be able to diagnose the latter condition with a debugger. A stack trace of your application (e.g. obtained by running it in gdb) should help greatly.

提交回复
热议问题