destructor doesnt return control to calling function

I am having some weird errors while trying to de-allocate memory. I have two class inspector and hypergraph. Both are singleton objects. I am trying to deallocate the memory for those. the inspector object is deleted from a client code. The inspector deallocates the hypergraph. But looks like after executing the destructor for the hypergraph class, control is not returned to the destructor of the inspector class.

Here is the code for the destructor for the inspector
1
2
3
4
5
6
hypergraph* curr_graph = hypergraph::instance();
printf("Before\n");
fflush(stdout);
delete curr_graph;
printf("Here 0\n");
fflush(stdout);


The destructor for the hypergraph object looks like this

1
2
3
4
5
6
7
8
9
10
11
hypergraph::~hypergraph()
{
  printf("Hyper 0\n");
  fflush(stdout);
  for( int i = 0 ; i < all_cells.size() ; i++ )
    delete all_cells[i];
  for( int i = 0 ; i < all_nets.size() ; i++ )
    delete all_nets[i];
  printf("Hyper 1\n");
  fflush(stdout);
}


When I run the code, the output looks like this:

Before
Hyper 0
Hyper 1


At this point the code hangs and I have to kill the program. Any ideas what might be happening?


Logging is a poor man's debugger. Try an actual debugger.

What happens when you step through the code?
Well, the actually code is in MPI. Using gdb with MPI is a pain. Hence the poor man's debugging. The code above through is called by only one process, so there is definitely no deadlocks happening
Topic archived. No new replies allowed.