I am assuming I am doing something wrong but I am hoping someone can
give me a clue as to where to look.

I'm trying to write an AIX device driver using g++.  The drivers do
not have a __start or main, so I have to call the global constructors
and destructors myself.  I've written code attempting to make sure
they get constructed before any globals are accessed and no global
access happens after they are destroyed.  But my trace shows that the
object that is suppose to do that is getting its destructor called
recursively.

The essence is that I have an automatic variable.  The constructor
calls the global constructors; the destructor calls the global
destructors.  Line 1 and 10 you see this variable's destructor getting
called.  The second call returns at line 13.  The first call returns
at line 23.  The second call does nothing because I have already
flipped the bit that says that the global destructors need to be
called.  So the second call comes and goes without much fuss.  The
only thing unusual about the config_lock class is it has two static
members.  I could move those and just have global C statics if
necessary.  The static members are an int and an lock_t (C types).

I can write code to cope with this but I assume that this is not
suppose to happen.  My fear is that I am trashing something and just
getting lucky that I am not crashing.  I first want to make sure (from
comments from this mailing list) that it is not suppose to happen.
The second thing I'm hoping for is some suggestions on what may be
happening.  The first call appears to be destroying objects, then
calls itself again, then continues destroying objects, then returns.
Why is it calling itself again?  Any ideas?

  1 **** config_lock_dtor
  2      get_lockl_ctor
  3      get_lockl_ctor ret 0 from line 108
  4      global_dtors
  5      global_dtors 004E 0000 0000 0000
  6      dtor
  7      dtor ret 0 from line 24
  8      dvr_simple_lock_dtor
  9      dvr_simple_lock_dtor ret 0 from line 31
10 **** config_lock_dtor
11      get_lockl_ctor
12      get_lockl_ctor ret 0 from line 108
13 **** config_lock_dtor ret 0 from line 75
14      get_lockl_dtor
15      get_lockl_dtor ret 0 from line 116
16      free ptr 70BDDFC0
17      free ret 0 from line 32
18      free ptr 70BCF480
19      free ret 0 from line 32
20      free ptr 70BCF820
21      free ret 0 from line 32
22      global_dtors ret 0 from line 82
23 **** config_lock_dtor ret 0 from line 75

Thank you for you help.
Perry Smith

Reply via email to