[Trilinos-Users] Unexpected Memory Issue with AztecOO

Corey A. Henderson cahenderson at wisc.edu
Thu Mar 24 22:49:01 EDT 2016


I am creating a solver class where I wish to reuse the same AztecOO
instance to repeatedly call the .Iterate() method as the b vector
changes in an Ax=b problem statement.

I encountered an unexpected memory error when using AztecOO as a class
member in C++. The AztecOO destructor throws a memory corruption core
dump when my instance is destroyed. I was able to resolve it by using
a pointer and allocating the instance on the heap and using delete in
my destructor, but I don't feel that should be necessary.

The "bug" I saw can be easily reproduced by creating an instance of
AztecOO on the stack and then triggering the destructor by replacing
it with another instance. Like so:

//AztecOOMemTest.cpp
#include "AztecOO.h"

int main(int argc, char **argv) {
    AztecOO solver;
    solver = AztecOO();
}

The error is:
*** Error in `./AztecOOMemTest': double free or corruption (fasttop):
0x0000000002496de0 ***
Aborted (core dumped)

Is this expected behaviour? The documentation is not really clear on
whether the default constructor is supported. I'm not a C++ expert so
it's also possible I am doing something really dumb.

Regards,

-- 
Corey A. Henderson
PhD Candidate and NSF Graduate Fellow
Dept. of Engineering Physics
Univ. of Wisconsin - Madison


More information about the Trilinos-Users mailing list