$ gdb ./sigsegv GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Reading symbols from ./sigsegv...done. (gdb) r Starting program: /tmp/sigsegv [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6f4e700 (LWP 68189)]
Thread 2 "sigsegv" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff6f4e700 (LWP 68189)] 0x0000000000400f5d in foo () at sigsegv.cc:8 8 std::cout << v[100] << std::endl;
(gdb) bt #0 0x0000000000400f5d in foo () at sigsegv.cc:8 #1 0x00000000004027dd in std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0x617c48) at /usr/include/c++/5/functional:1531 #2 0x0000000000402736 in std::_Bind_simple<void (*())()>::operator()() (this=0x617c48) at /usr/include/c++/5/functional:1520 #3 0x00000000004026c6 in std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (this=0x617c30) at /usr/include/c++/5/thread:115 #4 0x00007ffff7b0dc80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff76296ba in start_thread (arg=0x7ffff6f4e700) at pthread_create.c:333 #6 0x00007ffff735f41d inclone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
$ gdb ./exception GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Reading symbols from ./exception...done. (gdb) r Starting program: /tmp/exception [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6f4e700 (LWP 68143)] terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 100) >= this->size() (which is 0)
Thread 2 "exception" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff6f4e700 (LWP 68143)] 0x00007ffff728d428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt #0 0x00007ffff728d428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 #1 0x00007ffff728f02a in __GI_abort () at abort.c:89 #2 0x00007ffff7ae484d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff7ae26b6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff7ae2701 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff7b0dd38 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007ffff76296ba in start_thread (arg=0x7ffff6f4e700) at pthread_create.c:333 #7 0x00007ffff735f41d inclone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
$ gdb ./exception GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Reading symbols from ./exception...done. (gdb) r Starting program: /tmp/exception [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6f4e700 (LWP 68314)] terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 100) >= this->size() (which is 0)
Thread 2 "exception" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff6f4e700 (LWP 68314)] 0x00007ffff728d428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt #0 0x00007ffff728d428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 #1 0x00007ffff728f02a in __GI_abort () at abort.c:89 #2 0x00007ffff7ae484d in __gnu_cxx::__verbose_terminate_handler () at ../../../../src/libstdc++-v3/libsupc++/vterminate.cc:95 #3 0x00007ffff7ae26b6 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:47 #4 0x00007ffff7ae2701 in std::terminate () at ../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:57 #5 0x00007ffff7b0dd38 in std::execute_native_thread_routine (__p=<optimized out>) at ../../../../../src/libstdc++-v3/src/c++11/thread.cc:92 #6 0x00007ffff76296ba in start_thread (arg=0x7ffff6f4e700) at pthread_create.c:333 #7 0x00007ffff735f41d inclone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
$ g++-8 -g -std=c++11 exception.cc -o exception -pthread $ gdb ./exception GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Reading symbols from ./exception...done. (gdb) r Starting program: /tmp/exception [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6f42700 (LWP 69463)] terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 100) >= this->size() (which is 0)
Thread 2 "exception" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff6f42700 (LWP 69463)] 0x00007ffff7281428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt #0 0x00007ffff7281428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 #1 0x00007ffff728302a in __GI_abort () at abort.c:89 #2 0x00007ffff7ad78f7 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff7adda46 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff7adda81 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff7addcb4 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007ffff7ad97f5 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #7 0x0000000000401274 in std::vector<int, std::allocator<int> >::_M_range_check (this=0x7ffff6f41e00, __n=100) at /usr/include/c++/8/bits/stl_vector.h:960 #8 0x0000000000401033 in std::vector<int, std::allocator<int> >::at (this=0x7ffff6f41e00, __n=100) at /usr/include/c++/8/bits/stl_vector.h:981 #9 0x0000000000400dd7 in foo () at exception.cc:8 #10 0x00000000004013a7 in std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) ( __f=<unknown type in /tmp/exception, CU 0x0, DIE 0x6a01>) at /usr/include/c++/8/bits/invoke.h:60 #11 0x0000000000401093 in std::__invoke<void (*)()>(void (*&&)()) (__fn=<unknown typein /tmp/exception, CU 0x0, DIE 0x6e68>) at /usr/include/c++/8/bits/invoke.h:95 #12 0x00000000004019da in std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul> (this=0x615c28) at /usr/include/c++/8/thread:234 #13 0x000000000040199b in std::thread::_Invoker<std::tuple<void (*)()> >::operator() (this=0x615c28) at /usr/include/c++/8/thread:243 #14 0x0000000000401970 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run (this=0x615c20) at /usr/include/c++/8/thread:186 #15 0x00007ffff7b0857f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #16 0x00007ffff761d6ba in start_thread (arg=0x7ffff6f42700) at pthread_create.c:333 #17 0x00007ffff735341d inclone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109