You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2001/10/10 03:04:06 UTC

DO NOT REPLY [Bug 4059] New: - gScannerMutex returns dangling pointer after initialization, termination, and one more initialization

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4059>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4059

gScannerMutex returns dangling pointer after initialization, termination, and one more initialization

           Summary: gScannerMutex returns dangling pointer after
                    initialization, termination, and one more initialization
           Product: Xerces-C++
           Version: Nightly build
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Utilities
        AssignedTo: xerces-c-dev@xml.apache.org
        ReportedBy: mike_bos@mail.com


If the calling program does multiple cycles of XMLPlatformUtils::Initialize and
XMLPlatformUtils::Terminate, then the function gScannerMutex
(src/internal/XMLScanner.cpp) will return a dangling pointer to mutex when
called in the second init/term cycle.

The reason is that it uses a local static (scannerMutex) to keep the pointer to
the mutex it creates, and *also* registers the mutex in LazyData. So the mutex
is deleted on XMLPlatformUtils::Terminate leaving the static pointing to freed
memory. The next time gScannerMutex is called, it checks that the static is
non-zero and happily returns it.

The workaround is to call Initialize and Terminate in main() or whatever scope
encloses the code that does multiple init/term, to prevent Terminate from
actually freeing resources and LazyData more than once. But that creates
undesirable dependencies in the code.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org