I'm getting this error:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000407265 in Quadtree::deeper (this=0x7fffffffe430,
orig=@0x7fffffffe430, n=@0x7a1da0, tol=Cannot access memory at address 0x7fffff3feffc
) at quadtree.cpp:47
47 int Quadtree::deeper(QuadtreeNode * & orig, QuadtreeNode * & n, int tol, int tolNum) {
This is line 47:
int Quadtree::deeper(QuadtreeNode * & orig, QuadtreeNode * & n, int tol, int tolNum) {
Whats weird is that I am not getting any valgrind errors at all, but only gdb error and seg fault at run time. What can this error possibly mean in a general sense (without having to see the rest of my code)?
My best guess: you are seeing a stack overflow (What a coincidence, given the site we're on! :). I can't explain why Valgrind isn't catching it though: usually Valgrind uses the same stack size as the OS (at least on my system).
What this error means is that your code tried to access memory at address 0x7fffff3feffc
-- either a read or a write, but that address is not currently memory-mapped into your address space. The instruction that performed this illegal read or write was at memory address 0x0000000000407265
.
If the compiler gives you the line number of your function's opening brace as the offending line, it might be in the function's prologue (the part that saves registers to the stack). That's why I suspect you have a stack overflow.
On Linux, you can look at /proc/YOUR-PID/maps
to get a memory-map for the entire process. It will show you where the stack and heap are stored, as well as where the libraries are loaded. You could use this information to figure out what part of memory you've likely overflowed. Since the stack is usually (on Linux) placed at the very top of memory, you'll probably find that this very large address is very near to your stack.
Good luck!
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