I compiled all source files using GCC with options -O0 -g3, and then I ran the corresponding binary in GDB. After receiving a SIGABRT, I performed a backtrace.
Here is the "crash" output from the run in GDB:
terminate called recursively
terminate called recursively
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
terminate called recursively
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff5baf700 (LWP 6434)]
0x00007ffff6be9037 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
Here is the GDB backtrace (which immediately followed the output shown above):
(gdb) bt
#0 0x00007ffff6be9037 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff6bec698 in __GI_abort () at abort.c:90
#2 0x00007ffff7921e8d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff791ff76 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff791f089 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff791fbc1 in __gxx_personality_v0 () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff71a615b in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#7 0x00007ffff71a65b8 in _Unwind_Resume () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#8 0x0000000000445b5d in simulate4_NEJMdisutilities (P=..., NNSmode=true, NNScontrol=false) at ../simulation4.cpp:1846
#9 0x0000000000420f97 in Policy::evaluate (this=0x8ad368) at ../globals.cpp:686
#10 0x000000000041201b in OCBA_SC(std::vector<Policy, std::allocator<Policy> >&, double, int, int, int, double) [clone ._omp_fn.1] () at ../OCBA.cpp:616
#11 0x00007ffff73b586a in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1
#12 0x00007ffff6f81f8e in start_thread (arg=0x7ffff5baf700) at pthread_create.c:311
#13 0x00007ffff6cabe1d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
(gdb)
From frame #8, GDB seems to be claiming that the problem ensued from line 1846 in source file simulation4.cpp.
However, here is line 1846 (and surrounding lines):
1835 if(NORMAL && VALIDATION) {
1836 P.hist_PSAtest.print();
1837 P.hist_biopsy.print();
1838 P.hist_treatment.print();
1839 P.hist_getCancer.print();
1840 P.hist_getMetastasis.print();
1841 P.hist_death.print();
1842 P.hist_deathOther.print();
1843 P.hist_deathPCa.print();
1844
1845 prevalence.print();
1846 }
1847
1848 /* ------------ TESTING ------------ */
1849 #if SIMULATION4_DEBUG > 1
1850 cout << "After single execution of simulate4_NEJMdisutilities(Policy&,bool,bool):\n";
1851 cout << " Policy::QALY::sum() = " << P.QALYs.sum() << "\n";
1852 cout << " Policy::Year::sum() = " << P.Years.sum() << "\n";
1853 cout << "\n";
1854 #endif
1855 /* --------------------------------- */
1856
1857
1858 } //simulate4_NEJMdisutilities()
What could explain the discrepancy between the line numbers?
As background, I should note that I am using std::vector::at() calls in simulation4.cpp instead of the [] operator, specifically because I'm suspicious that there may be a memory corruption somewhere. Prior to switching to the at() method, I was receiving a seg fault.
I should also note that VALIDATION=false in my run, so none of the code on lines 1836--1845 is executed.
Do you have many macros in the code? If you have a lot of multi-line pre-compiler expansions (multi-line macros for example) then your "code" is modified to include that by the pre-processor before linking happens. These count as lines of code and so can throw off your debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With