Unable to access memory with address error

I get 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) { 

It is strange that I am not getting any valgrind errors, but only a gdb error and a seg error at runtime. What can this error mean in a general sense (without having to see the rest of my code)?

+6
c ++
source share
2 answers

My best guess: you see a stack overflow (What a coincidence, given the site we're on! :). I canโ€™t explain why Valgrind will not catch it: usually Valgrind uses the same stack size as the OS (at least on my system).

This error means that your code tried to access memory at address 0x7fffff3feffc - both read and write, but this address is not currently displayed in your address space. The instruction that performed this illegal reading or writing was located at memory address 0x0000000000407265 .

If the compiler gives the line number of your function that opens the bracket as a violation line, it may be in the prologue of the function (the part that stores the registers on the stack). Therefore, I suspect you have a stack overflow.

On Linux, you can look at /proc/YOUR-PID/maps to get a memory card for the whole process. It will show you where the stack and heap are stored, as well as where the libraries are loaded. You can use this information to find out how much memory you are likely to overflow. Since the stack is usually (on Linux) located at the very top of the memory, you will probably find that this very large address is very close to your stack.

Good luck

+12
source share

Make sure that neither orig , nor n , nor the Quadtree object you call deeper has been freed (deleted).

0
source share

All Articles