figure_size() still crashes with segmentation fault
Following the closed issue #114, I still get a segmentation fault on call to figure_size(). I get the error on one machine and not on the other. Both running Ubuntu and gcc. The error I guess happens at the following call inside figure_size():
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_figure, ....
but it manifests itself only at the main() program exit. It means that the error causing call of figure_size() does not affect program execution following the call, e.g, plot() and show(). I believe, it is someway related to freeing resources, however, I cannot inspect the library function PyObject_Call() to find more.
The issue is manifested on Ubuntu 20.04 w/Python 3.8, while it doesn't show up on Ubuntu 18.04 w/Python 3.6.
Apparently, the fault also happens when the call to figure_size() is not explicit but implicit, possibly with a call to plot() or show(). On the other hand, a plain main() program consisting of a single call to figure_size() is sufficient to get the error.
See issue #268 and the proposed fix. Add
plt::detail::_interpreter::kill();
in main, before return. Alternatively, you may be able to fix it by changing the backend to TkAgg, although I haven't tried it. Follow the stackoverflow link in that post for more details.