Segmentation fault in std::map::insert(…)

这一生的挚爱 提交于 2019-12-05 07:43:31

From what I can see, I would venture that the really important code is missing.

As noted: this=0x407a59, __x=@0x7fffffff0b50, __y=@0x758948f87d894905 is quite strange, the addresses are way too apart, so we can suppose that one of them (at least) is simply uninitialized. And for my own sanity I'll suppose that your implementation of std::map is not buggy.

My gut feeling would be to look for an uninitialized map, and therefore, and uninitialized VoteContainer object. Would you have some VoteContainer* that you forgot to allocate before invoking registerVote on it ?

If you working under Linux, I can recommend valgrind tool, it should help you to find where is the problem

Two guesses:

  1. Can you show the code calling the registerVote() method? (I suspect that may give some clue.)

  2. Can you put

    m_votes.clear();

in the VoteContainer constructor?

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