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/11724] New: ld.so - Initialization and Termination Functions incorrectly ordered


The order of initialization and termination functions called when loading or
exiting via the loader is being sorted incorrectly in particular cases
(described below) according to the TIS ELF 1.2 standard:

"Before the initialization code for any object A is called, the initialization
code for any other objects that object A depends on are called."

The partial sorting algorithm used in elf/dl-deps.c and elf/dl-fini.c is
incorrect when the sorting section is reached with a particular (order
dependent) dependency hierarchy.  I have not been able to boil down to a
canonical example, but have anonymized it, and will attach following submission.
 Additionally, the partial sort is not input-order independent, as multiple runs
of the existing sort on the failure set, repeating if dependencies are found out
of order, is convergent.

The partial sort is not sufficient to perform the dependency analysis on all
inputs given the requirements of the standards doc, and I have drafted a patch
which uses the tsort implementation from coreutils.  This new sorting has been
tested on all cases where the current ld.so initializes things in the incorrect
order, and on a number of other programs.  The inability to reliably initialize
objects in the correct order is a major issue for me, particularly when working
with C++ and globally initialized variables dependent on linked objects'
initializations.

-- 
           Summary: ld.so - Initialization and Termination Functions
                    incorrectly ordered
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: werkt0 at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-linux-gnu
  GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu


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

------- 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]