Application gives segmentation fault randomly in python extension functions in c++

只愿长相守 提交于 2019-12-05 12:26:51
Jack

I got solution for this problem which has ultimately gave me as well as my client huge relief.

And here is the reason and solution.

The functions “sa_GetBlue” and "sa_GetRed" was returning “Py_False”. Before returning “Py_False” or “Py_True” you need to increase the reference count of the variable holding these values otherwise It may corrupt memory state of the interpreter; it would not crash immediately but may crash at any point of time. In my case, It was crashing after processing 20000 to 50000 requests.

Please check below link to get more idea about what I am trying to explain.

why-does-python-keep-a-reference-count-on-false-and-true

@doomster and @Omnifarious; Thank you for your comment and direction that you have provided.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!