This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/4650] New: Destructor for the global object defined in a static library is called more than once


Let us have:

1. Static library (St1) with global object (g_O) 
2. Shared library Sh1 which links St1. 
3. Shared library Sh2 which links St1. 
4. Executable which dynamically loads Sh1 and Sh2. 

During the load of Sh1 global object g_O is created at memory address, for
example, 0x01 (i.e. `this' pointer refers to 0x01). During the load of Sh2
global object g_O initialized once more, and if Sh1 was not unloaded yet g_O?s
`this' pointer refers to 0x01 .  Thus when Sh1 is unloaded object g_O at address
0x01 is destroyed and when Sh2 unloaded g_O at 0x01 destroyed once more.

Steps to reproduce:

1. Unpack the attached tarball. It contains the test case for the situation
described above.
2. Run "gmake" to compile the test case.
3. Change dir to the newly created ./bin
4. Run "./double_destruction"

Actual results:

Loading libmaster.so
this(0x8EAC20) ctor(Global)
this(0x8EAC20) out(master self)
Loading libslave.so
this(0x8EAC20) ctor(Global)
this(0x8EAC20) out(slave self)
this(0x8EAC20) dtor
this(0x8EAC20) dtor should not be called more than once!!!

That is:
Shared library libmaster.so is loaded 
Constructor of the global object is called
Some method of the global object is executed
Shared library libslave.so is loaded
Constructor of the same global object is called once more
Some method of the global object is executed
Destructor of the global object is called
Destructor of the same global object is called once more

Expected results:

Loading libmaster.so
this(0x8EAC20) ctor(Global)
this(0x8EAC20) out(master self)
Loading libslave.so
this(0x8EAC20) out(slave self)
this(0x8EAC20) dtor

Found on: 
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
Compiled on a Linux 2.4.20 system on 2005-02-22.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        Native POSIX Threads Library by Ulrich Drepper et al
        The C stubs add-on version 2.1.2.
        BIND-8.2.3-T5B
        NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
        Glibc-2.0 compatibility add-on by Cristian Gafton
        GNU Libidn by Simon Josefsson
Thread-local storage support included.

Glibc version used for reproduction:

GNU C Library development release version 2.6.90, by Roland McGrath et al.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.6.
Compiled on a Linux 2.4.20 system on 2007-06-14.
Available extensions:
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
        software FPU emulation by Richard Henderson, Jakub Jelinek and others

GCC -v:
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.6/specs
Configured with: ../gcc-3.4.6/configure
Thread model: posix
gcc version 3.4.6

ld -v:
GNU ld version 2.15.92.0.2 20040927

-- 
           Summary: Destructor for the global object defined in a static
                    library is called more than once
           Product: glibc
           Version: 2.3.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: alexeyk at edifecs dot com
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=4650

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]