Log4cxx
  1. Log4cxx
  2. LOGCXX-112

change "static" to "auto" for Transcoder::decode() decoder and CharsetDecoder::getDefaultDecoder() decoder

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None

      Description

      Hi

      The following patch is a dirty hack and I assume you will want to have it in a totally different way. But it fixes the crash I get. So far it seems that Transcoder::decode() can get called (from the destructors of static objects) even after it's internal static variables get destroyed (thus decrementing the reference count, thus destroying the referenced object eventually thus having the codes dereference an invalid pointer).

      The problem is also present in the ::encode() functions and their "encoder" variable (but it didnt bite my program yet, so I left it there).

      1. staticdestruct.patch
        2 kB
        Curt Arnold
      2. log4cxx-static-fix2.diff
        1 kB
        Mihai Rusu

        Issue Links

          Activity

          Hide
          Curt Arnold added a comment -

          I'd appreciate feedback if this patch fixes the reporter's problem. Basically, it tweaks the ObjectPtr destructor so that it zero its memory on destruction and then modifies the getDefaultEncoder and getDefaultDecoder so if they are called after their local static has been destructed, they will give you a newly constructed encoder or decoder. Since logging during static object destruction should be relatively rare, the additional overhead should be small.

          Show
          Curt Arnold added a comment - I'd appreciate feedback if this patch fixes the reporter's problem. Basically, it tweaks the ObjectPtr destructor so that it zero its memory on destruction and then modifies the getDefaultEncoder and getDefaultDecoder so if they are called after their local static has been destructed, they will give you a newly constructed encoder or decoder. Since logging during static object destruction should be relatively rare, the additional overhead should be small.
          Hide
          Curt Arnold added a comment -

          Committed in rev 371607. Only way to be safe when logging in static object destructor is to ensure that there are equivalent logging calls in constructor. If the logging system (or any of its resources) is initialized after the constructor, they will be released before the destructor is called. The encoders and decoders are pretty cheap to reconstruct, but don't want to be rereading configuration files etc on application shutdown.

          Show
          Curt Arnold added a comment - Committed in rev 371607. Only way to be safe when logging in static object destructor is to ensure that there are equivalent logging calls in constructor. If the logging system (or any of its resources) is initialized after the constructor, they will be released before the destructor is called. The encoders and decoders are pretty cheap to reconstruct, but don't want to be rereading configuration files etc on application shutdown.

            People

            • Assignee:
              Curt Arnold
              Reporter:
              Mihai Rusu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development