When my exe exiting after python script finish,I got a error point to crt0dat.c

The call stack like this…

Are there some error in my c++ code or in the python code?
the c++ code like this:
void PythonCall::call(std::vector<double>& s,std::vector<double>& b,std::vector<double>& t,std::vector<double>& y)
{
PyObject* args = PyTuple_New(2);
PyObject* tPyList = convert2PythonList(t);
PyObject* yPyList = convert2PythonList(y);
PyTuple_SetItem(args,0,tPyList);
PyTuple_SetItem(args,1,yPyList);
PyObject* r = PyObject_CallObject(func,args);
PyObject* item;
PyObject* iter = PyObject_GetIter(r);
/*{
PyObject *errtype, *errvalue, *traceback;
PyErr_Fetch(&errtype, &errvalue, &traceback);
PyObject *s = PyObject_Str(errvalue);
char *errstr = PyString_AsString(s);
std::cout << "Python Error: " << errstr;
}*/
item = PyIter_Next(iter);
int i = 0;
PyObject* iter2 = PyObject_GetIter(item);
PyObject* item2;
while (item2 = PyIter_Next(iter2))
{
s[i] = PyFloat_AsDouble(item2);
Py_XDECREF(item2);
i++;
}
Py_XDECREF(item);
//Py_XDECREF(iter2);
item = PyIter_Next(iter);
i = 0;
iter2 = PyObject_GetIter(item);
while (item2 = PyIter_Next(iter2))
{
b[i] = PyFloat_AsDouble(item2);
Py_XDECREF(item2);
i++;
}
Py_XDECREF(item);
//Py_XDECREF(iter2);
//Py_XDECREF(iter);
Py_XDECREF(args);
Py_XDECREF(r);
Py_XDECREF(item);
Py_XDECREF(tPyList);
Py_XDECREF(yPyList);
//std::cout << "done" << std::endl;
}
and the python code:
def get_slope_baseLine(tl,xl):
slopes = get_slope2(tl,xl)
baselines = get_leakTime(tl,slopes)
return slopes,baselines
sorry about my poor English…
Apparently you’re intending to iterate over two lists and decrement the ref counts of their elements, but you forget to reset
iterso you’re not iterating over the second list.The crash may however be due to other reasons (it depends on the documented behavior of the functions you’re using).