Seg Fault when removing edges

*** Aborted at 1584830168 (unix time) try "date -d @1584830168" if you are using GNU date ***                                                                          [1/1894]
PC: @                0x0 (unknown)                                                                                                                                             
*** SIGSEGV (@0x0) received by PID 149061 (TID 0x7f5c9230a740) from PID 0; stack trace: ***
    @     0x7f5c91f07890 (unknown)
    @     0x7f5b4580b0fa boost::remove_edge<>()
    @     0x7f5b4580b7a9 graph_tool::remove_edge()
    @     0x7f5b457cab5a boost::python::objects::caller_py_function_impl<>::operator()()
    @     0x7f5b43f024cd boost::python::objects::function::call()
    @     0x7f5b43f02639 boost::detail::function::void_function_ref_invoker0<>::invoke()
    @     0x7f5b43f0930b boost::python::detail::exception_handler::operator()()
    @     0x7f5b448a0c14 boost::detail::function::function_obj_invoker2<>::invoke()
    @     0x7f5b43f092da boost::python::detail::exception_handler::operator()()
    @     0x7f5b448a0bc4 boost::detail::function::function_obj_invoker2<>::invoke()
    @     0x7f5b43f092da boost::python::detail::exception_handler::operator()()
    @     0x7f5b448a0ae4 boost::detail::function::function_obj_invoker2<>::invoke()
    @     0x7f5b43f0908f boost::python::handle_exception_impl()
    @     0x7f5b43eff6fa function_call
    @     0x560abeccc6db _PyObject_FastCallDict
    @     0x560abed53efe call_function
    @     0x560abed7666a _PyEval_EvalFrameDefault
    @     0x560abed4debb fast_function
    @     0x560abed53e85 call_function
    @     0x560abed7666a _PyEval_EvalFrameDefault
    @     0x560abed4d57e _PyEval_EvalCodeWithName
    @     0x560abed4e0f1 fast_function
    @     0x560abed53e85 call_function
    @     0x560abed7666a _PyEval_EvalFrameDefault
    @     0x560abed4debb fast_function
    @     0x560abed53e85 call_function
    @     0x560abed7666a _PyEval_EvalFrameDefault
    @     0x560abed4ec09 PyEval_EvalCodeEx
    @     0x560abed4f9ac PyEval_EvalCode
    @     0x560abedcfc64 run_mod
    @     0x560abedd0061 PyRun_FileExFlags
    @     0x560abedd0263 PyRun_SimpleFileExFlags
Segmentation fault (core dumped)

I'm attaching the code that throws this error.

    ug.set_fast_edge_removal()
    ug_bb = ug.new_edge_property('double')
    for e in ug.edges():
        u = ug.vp.mw[e.source()]
        v = ug.vp.mw[e.target()]
        if ug.ep.w[e] is not u and u >= v:
            bb = ug.ep.w[e] / u
            if bb <= 1 and len([ae[0] for ae in ug.get_all_edges(e.source())]) > 1:
                node = e.source()
                ug.remove_edge(e)
                print('Edge removed')
                ug.vp.mw[node] = max([ug.ep.w[ug.edge(ae[0], ae[1])] for ae in ug.get_all_edges(node)])
            else:
                ug_bb[e] = bb
        elif ug.ep.w[e] is not v and v >= u:
            bb = ug.ep.w[e] / v
            if bb <= 1 and len([ae[0] for ae in ug.get_all_edges(e.target())]) > 1:
                node = e.target()
                ug.remove_edge(e)
                print('Edge removed')
                ug.vp.mw[node] = max([ug.ep.w[ug.edge(ae[0], ae[1])] for ae in ug.get_all_edges(node)])
            else:
                ug_bb[e] = bb

So depending on the run I'd remove a certain number of edges before it throws a seg fault.

Edited by Chang Kim