Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-159

Initialization of local static objects out of order on Linux

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • Build
    • None
    • Linux (Redhat FC5), gcc-4.1.1, GNU ld 2.16, APR 1.2.2, APR-util 1.2.7

    Description

      (There is a bug that describes similar symptoms, LOGCXX-112, now closed; I couldn't figure out how to re-open it).

      I'm getting SEGFAULTs while trying to access log4cxx functions from a destructor of a global class instance. After some digging here's what I found: it seems that local static variables used by some log4cxx functions get destructed too early, (e.g., the string in NDC::getNull). The destructors of these object get called before the static destructors of user classes (I verified this in a debugger). I can also demonstrate this behavior in a completely isolated (not using log4cxx), simple program. I actually suspect this may be a "feature" of gcc and/or GNU ld, not necessarly a problem with log4cxx, since like I said it happens consitently with or without log4cxx code.

      I'm quite sure changing local static vars to be global (either standalone or as static class-members) will solve this.

      Attachments

        1. LOGCXX-159_standalone_test.tar.gz
          0.9 kB
          Davlet Panech
        2. LOGCXX-159_static_locals.patch
          21 kB
          Davlet Panech
        3. main.cpp
          0.4 kB
          Davlet Panech

        Issue Links

          Activity

            People

              carnold@apache.org Curt Arnold
              dpanech Davlet Panech
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: