0

I have two threads running in a program. They are created using boost::thread.

The two threads do not share anything in terms of memory. No data-structures or objects are shared between them.

Now the second thread uses a class which has as private members a lot of Eigen double Matrices. I make sure that the matrices are aligned using the Eigen directive EIGEN_MAKE_ALIGNED_OPERATOR_NEW etc

When the first thread is running the elements at the matrices of the second class are over-written . I checked that by inspections since elements that should be decimals suddenly become integers. When the first thread is not running the second has no problem and its Eigen members have correct values.

Again: 1) The two threads share no data structures. 2) There is no segmentation fault message or something similar or some error message while the program is running. 3) Any suggestions how to protect the memory of the second thread or how to track done how the memory is violated?

Thank you in advance. I am really sorry I did not post code but it is huge. Let me know if you want me to post something specific from the code.

user1194167
  • 117
  • 9
  • This isn't a memory leak. A memory leak refers to memory/objects that are allocated and not freed/deleted. This sounds like the first thread is referencing memory through a bogus pointer. This often happens when an object is deleted, but the program maintains a defunct pointer to it. – deemer Jul 18 '12 at 19:56

1 Answers1

0

You likely want a debugging tool like mallocguard for Mac or Electric Fence for Linux.

These work by adding "Guard Pages" before allocations which mark them as inaccessible virtual memory. When the memory is freed, it too is marked as inaccessibile. If the program attempts to access memory that it shouldn't, the modified allocator ensures that it crashes immediately, so that your debugger will hopefully highlight the line of code that was causing the corruption. Beware that this can consume large amounts of memory, so you'll potentially need a small data set that reproduces the corruption.

deemer
  • 1,142
  • 8
  • 10