c++ EXC_BAD_ACCESS error, how to debug

992 views Asked by At

I do compile my code without any error and when I run it, I get segmentation fault 11. After tracing the code with lldb, I reached EXC_BAD_ACCESS error in the code below. The problem is that the lines it says there is an error is not in my code. So I do not know what to do to debug the code.

Any help appreciated, thanks in any advance. Here is the error message:

* thread #1: tid = 0x17be3, 0x000000010000393f p1ex01`Tree<int, std::__1::less<int> >::Tree(std::__1::list<int, std::__1::allocator<int> > const&) [inlined] std::__1::deque<int, std::__1::allocator<int> >::back(this=0x00007fff5fbfe868 size=0) + 96 at deque:1752, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x000000010000393f p1ex01`Tree<int, std::__1::less<int> >::Tree(std::__1::list<int, std::__1::allocator<int> > const&) [inlined] std::__1::deque<int, std::__1::allocator<int> >::back(this=0x00007fff5fbfe868 size=0) + 96 at deque:1752
1749    deque<_Tp, _Allocator>::back()
1750    {
1751        size_type __p = __base::size() + __base::__start_ - 1;
-> 1752     return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1753    }
1754    
1755    template <class _Tp, class _Allocator>
1

There are 1 answers

0
Armali On BEST ANSWER

Type 'bt' when that error occurs. That will give you the function call backtrace. – Joel Cornett