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/03/07 12:31:40 UTC
[Bug 880] New - XMLPlatformUtils::Terminate cannot be called more than once.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=880
*** shadow/880 Wed Mar 7 03:31:40 2001
--- shadow/880.tmp.4376 Wed Mar 7 03:31:40 2001
***************
*** 0 ****
--- 1,65 ----
+ +============================================================================+
+ | XMLPlatformUtils::Terminate cannot be called more than once. |
+ +----------------------------------------------------------------------------+
+ | Bug #: 880 Product: Xerces-C |
+ | Status: NEW Version: 1.4 |
+ | Resolution: Platform: All |
+ | Severity: Minor OS/Version: All |
+ | Priority: Component: Utilities |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xerces-c-dev@xml.apache.org |
+ | Reported By: mfazekas@graphisoft.hu |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ The following program won't work:
+
+ #include <parsers/SAXParser.hpp>
+ #include <util/PlatformUtils.hpp>
+ int main(int argC, char* argV[])
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ XMLPlatformUtils::Initialize();
+
+ SAXParser parser;
+
+ XMLPlatformUtils::Terminate();
+ }
+ return 0;
+ }
+ (100% reproducible on WindowNT2000)
+
+ The problem is with the gScannerMutex function.
+ XMLPlatformUtils::Terminate deletes the scannerMutex global, but it won't be
+ null-ed. So call of gScannerMutex after Terminate causes a call to member
+ function of an already deleted object. (As scannerMutex is deleted but it's not
+ null.)
+
+ One possible fix is modifying XMLDeleterFor object. So that it will null-the
+ data after deleting it.
+ So instead
+ > new XMLDeleterFor<XMLMutex>(scannerMutex)
+ [ line 129 of XMLScanner.cpp ]
+ we would use:
+ new XMLDeleterFor<XMLMutex>(&scannerMutex);
+
+ And of course XMLDeleterFor should be changed:
+
+ template <class T> XMLDeleterFor<T>::~XMLDeleterFor()
+ {
+ delete *fToDelete;
+ *fToDelete = NULL; // new
+ }
+
+ It's constuctor prototype would be:
+ XMLDeleterFor(T** toDelete);
+
+ Note that it's also possible to use references instead of pointers in the
+ XMLDeleterFor(T*& toDelete); . In this case the modification of XMLDeleterFor
+ solves a problem.
+
+ Regards,
+ Mikl�s.