Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callstack for std::bad_function_call

Tags:

c++

linux

c++11

I have a linux program which terminates with:

terminate called after throwing an instance of 'std::bad_function_call'

In the call stack I sadly don't see from where the bad function is called. Also it does very much iterations before generating this error, so I cannot really debug it by hand.

Is there a way to get to the problematic piece of code?

like image 691
abergmeier Avatar asked Apr 09 '13 15:04

abergmeier


3 Answers

Can you set a catchpoint from gdb? You'll want to execute

catch throw

from gdb command line before running the program, and then a breakpoint will be hit when an exception is thrown.

like image 196
Nemanja Trifunovic Avatar answered Oct 20 '22 22:10

Nemanja Trifunovic


You can use gdb to see where the exception is being thrown:

(gdb) catch throw

That will stop whenever a new exception is thrown in your program, and you will see where it happened.

like image 27
David Rodríguez - dribeas Avatar answered Oct 20 '22 22:10

David Rodríguez - dribeas


please reference to this website. In my case, this problem was caused by using null function pointer. http://www.cplusplus.com/reference/functional/bad_function_call/

like image 1
冯剑龙 Avatar answered Oct 20 '22 20:10

冯剑龙