开发者

SIGABRT when trying to throw an exception

I have a very strange problem, which took already several hours of my attention:

With giving a wrong input to the software I am working on, I can produce an exception (which is of course intended). This works fine and I see a correct error message when executing the program. But when I pass the exact same input over the API (which yields to nearly the same control flow), the program crashes. With debugging I see the following (I use gdb for debugging):

    开发者_如何学Go
  • The Exception class (in this case called UserExcption and this class has no virtual methods and also its predecessors don't have any virtual methods) gets successfully instantiated.
  • When I step "into the throw statement" (want to say that I just continue to step after the exception object is instantiated) I get the following output:

(gdb) s

pure virtual method called

Program received signal SIGABRT, Aborted.

0x00007fff95c64ce2 in __pthread_kill ()

(gdb)

I really do not understand what happens here. Since now virtual methods at all are involved (as far as I see), I also cannot imagine, that there are some dangling pointers or something like this (otherwise I would expect to get a null pointer exception). Since the whole program is quite big and I don't have any idea where to look for the problem I also cannot reproduce it.

Does anyone have an idea what the source of such a behavior could be?

Best Markus


I wonder if you are calling some (not pure) virtual method from either a constructor or destructor, or possibly some cast going wrong. You should check this in your exception class, I guess, since you get the error while throwing one instance of it.

Indeed, the compiler will prevent you from having a class with a not implemented pure virtual function. On the other side, virtual function polymorphism is not entirely safe in constructor and destructors.

Just a suggestion, but without seeing the code, this is just an hypothesis.

I would also make a clean build, maybe you have some stale objects for some reason.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜