Log4cxx
  1. Log4cxx
  2. LOGCXX-140

Handle leak with LoggingEvent::getCurrentThreadName

    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
    • Environment:
      Win32

      Description

      apr_os_thread_current leaks a handle for each spawned thread (see also documentation for revision 64133 of apr's win32/thread.c).

      I suppose that the actual intend was to print the thread id in stead of the thread handle. It would be much more convenient to have the tid (thread id) because tools such as "pslist" print also this tid. The thread handle is not very meaningful at this point.

      Since the Win32-API function GetCurrentThreadId() is not provided by the apr library, I suggest following (ugly) patch:

      const LogString LoggingEvent::getCurrentThreadName() {
      #if APR_HAS_THREADS
      //return StringHelper::formatHex((const void*) apr_os_thread_current());
      return StringHelper::formatHex((const void*) GetCurrentThreadId()); // CS 16-05-2006 due to handle leak
      #else
      return LOG4CXX_STR("0x00000000");
      #endif
      }

        Activity

        Hide
        Curt Arnold added a comment -

        Not only is the patch ugly, but it is Windows specific. Thanks for the report though and will investigate.

        Show
        Curt Arnold added a comment - Not only is the patch ugly, but it is Windows specific. Thanks for the report though and will investigate.
        Hide
        Curt Arnold added a comment -

        Committed equivalent patch in rev 467164.

        Show
        Curt Arnold added a comment - Committed equivalent patch in rev 467164.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development