You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Hans CH <hs...@pm-medici.ch> on 2006/12/12 08:13:33 UTC

MAC OS X 10.3.9 / Quark 6.5 XTension / Xerces 2.1: QuarkXPress crashs

Hi

I develop an XTension for Quark XPress 6.5 (Macintosh / Mac OS X 10.3.9)
using Codewarrior 8.3. In this XTension I use Xerces (2.1) to parse a XML
file. QuarkXPress itself has Xerces implemented in Avenue (to handle XML
douments).

I use Xerces in the following way:

-- BEGIN -----
...
XMLPlatformUtils::Initialize();
SAX2XMLReader* pXMLParser = XMLReaderFactory::createXMLReader();

pXMLParser->setFeature(XMLUni::fgSAX2CoreValidation, true); 
pXMLParser->setFeature(XMLUni::fgXercesDynamic, true);

pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);          //
Processing namespace enabled
pXMLParser->setFeature(XMLUni::fgXercesSchema, true);                //
Processing schema enabled
pXMLParser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);   // Full
schema constraint checking processing disabled
pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, false);  // 
pXMLParser->Namespace-prefixes feature disabled

// Content- and Errorhandler
int errorCount = 0;
int errorCode = 0;
try {
  CGenerateFromXMLHandler oHandler(m_iProcess, m_sXMLFile);	// my handler
  pXMLParser->setContentHandler(&oHandler);
  pXMLParser->setErrorHandler(&oHandler);
#if MACOS
  pXMLParser->parse(sXMLFile.c_str());
#else
  pXMLParser->parse(m_sXMLFile.c_str());
#endif
  errorCount = pXMLParser->getErrorCount();
  delete pXMLParser;
}
XMLPlatformUtils::Terminate();
...
-- END -------

This code is called in a loop for different XML files, this means
"XMLPlatformUtils::Initialize();", "SAX2XMLReader* pXMLParser =
XMLReaderFactory::createXMLReader();" and "XMLPlatformUtils::Terminate();"
are called one time for every run in the loop.

During the parsing a QuarkXPress document is opened, boxes and text is set
and so on. Different API functions of the QuarkXPress XDK for the
development of XTensions are used for that.

The problem is that QuarkXPress crashs sooner or later with an "access fault
exception" (memory) if I do that on this way. Sometimes it works, sometimes
not. Sometimes I can parse the XML files, but if I repeat the same test it
crashs. It seems to be a problem with Xerces, but I have no idea what the
problem could be. I have tested my code for memory problems but it seems to
be OK. I also comment out some code pieces in my XTension, but XPress crashs
anyway (on another place of the code). When I comment out the Xerces part in
my XTension it works, no crash. But of course I can do that only for
testing, I need Xerces in my Xtension.

- Is there maybe a problem if I call "XMLPlatformUtils::Initialize();" and
"XMLPlatformUtils::Terminate();" again and agin?
- Is there maybe a problem if QuarkXPress itself call one of this methods (I
don't know if it is so)?
- Maybe a memory problem?
- Is there a generally problem in Mac OS X 10.3.9 with Xerces?
- Maybe a problem in my code?

I have tried the same with Xerces 2.7, but it is the same problem.

Thanks for any help and support.

Best regards
Hans Stössel
-- 
View this message in context: http://www.nabble.com/MAC-OS-X-10.3.9---Quark-6.5-XTension---Xerces-2.1%3A-QuarkXPress-crashs-tf2805928.html#a7828432
Sent from the Xerces - C - Users mailing list archive at Nabble.com.


RE: MAC OS X 10.3.9 / Quark 6.5 XTension / Xerces 2.1: QuarkXPress crashs

Posted by Jesse Pelton <js...@PKC.com>.
It may still be possible to run afoul of Quark's Initialize()/Terminate() calls if XTensions run in the same process space as the application but a different thread.  If this is the case, you'd need to know something about how and when Quark makes these calls (and possibly whether they provide some sort of synchronization object that you can use) to guarantee that only one thread is running one of these functions at any given time.

-----Original Message-----
From: Alberto Massari [mailto:amassari@datadirect.com] 
Sent: Tuesday, December 12, 2006 3:07 AM
To: c-users@xerces.apache.org
Subject: Re: MAC OS X 10.3.9 / Quark 6.5 XTension / Xerces 2.1: QuarkXPress crashs

Hi Hans,
the model Initialize/do stuff/Terminate is highly 
dangerous, because Initialize and Terminate are 
not thread safe. But, if you put a guard to their 
invocation, and ensure that you don't touch any 
Xerces API or memory after calling Terminate you should be fine.

Alberto

At 23.13 11/12/2006 -0800, Hans CH wrote:

>Hi
>
>I develop an XTension for Quark XPress 6.5 (Macintosh / Mac OS X 10.3.9)
>using Codewarrior 8.3. In this XTension I use Xerces (2.1) to parse a XML
>file. QuarkXPress itself has Xerces implemented in Avenue (to handle XML
>douments).
>
>I use Xerces in the following way:
>
>-- BEGIN -----
>...
>XMLPlatformUtils::Initialize();
>SAX2XMLReader* pXMLParser = XMLReaderFactory::createXMLReader();
>
>pXMLParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
>pXMLParser->setFeature(XMLUni::fgXercesDynamic, true);
>
>pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);          //
>Processing namespace enabled
>pXMLParser->setFeature(XMLUni::fgXercesSchema, true);                //
>Processing schema enabled
>pXMLParser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);   // Full
>schema constraint checking processing disabled
>pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, false);  //
>pXMLParser->Namespace-prefixes feature disabled
>
>// Content- and Errorhandler
>int errorCount = 0;
>int errorCode = 0;
>try {
>   CGenerateFromXMLHandler oHandler(m_iProcess, m_sXMLFile);     // my handler
>   pXMLParser->setContentHandler(&oHandler);
>   pXMLParser->setErrorHandler(&oHandler);
>#if MACOS
>   pXMLParser->parse(sXMLFile.c_str());
>#else
>   pXMLParser->parse(m_sXMLFile.c_str());
>#endif
>   errorCount = pXMLParser->getErrorCount();
>   delete pXMLParser;
>}
>XMLPlatformUtils::Terminate();
>...
>-- END -------
>
>This code is called in a loop for different XML files, this means
>"XMLPlatformUtils::Initialize();", "SAX2XMLReader* pXMLParser =
>XMLReaderFactory::createXMLReader();" and "XMLPlatformUtils::Terminate();"
>are called one time for every run in the loop.
>
>During the parsing a QuarkXPress document is opened, boxes and text is set
>and so on. Different API functions of the QuarkXPress XDK for the
>development of XTensions are used for that.
>
>The problem is that QuarkXPress crashs sooner or later with an "access fault
>exception" (memory) if I do that on this way. Sometimes it works, sometimes
>not. Sometimes I can parse the XML files, but if I repeat the same test it
>crashs. It seems to be a problem with Xerces, but I have no idea what the
>problem could be. I have tested my code for memory problems but it seems to
>be OK. I also comment out some code pieces in my XTension, but XPress crashs
>anyway (on another place of the code). When I comment out the Xerces part in
>my XTension it works, no crash. But of course I can do that only for
>testing, I need Xerces in my Xtension.
>
>- Is there maybe a problem if I call "XMLPlatformUtils::Initialize();" and
>"XMLPlatformUtils::Terminate();" again and agin?
>- Is there maybe a problem if QuarkXPress itself call one of this methods (I
>don't know if it is so)?
>- Maybe a memory problem?
>- Is there a generally problem in Mac OS X 10.3.9 with Xerces?
>- Maybe a problem in my code?
>
>I have tried the same with Xerces 2.7, but it is the same problem.
>
>Thanks for any help and support.
>
>Best regards
>Hans Stössel
>--
>View this message in context: 
>http://www.nabble.com/MAC-OS-X-10.3.9---Quark-6.5-XTension---Xerces-2.1%3A-QuarkXPress-crashs-tf2805928.html#a7828432
>Sent from the Xerces - C - Users mailing list archive at Nabble.com.


Re: MAC OS X 10.3.9 / Quark 6.5 XTension / Xerces 2.1: QuarkXPress crashs

Posted by Alberto Massari <am...@datadirect.com>.
Hi Hans,
the model Initialize/do stuff/Terminate is highly 
dangerous, because Initialize and Terminate are 
not thread safe. But, if you put a guard to their 
invocation, and ensure that you don't touch any 
Xerces API or memory after calling Terminate you should be fine.

Alberto

At 23.13 11/12/2006 -0800, Hans CH wrote:

>Hi
>
>I develop an XTension for Quark XPress 6.5 (Macintosh / Mac OS X 10.3.9)
>using Codewarrior 8.3. In this XTension I use Xerces (2.1) to parse a XML
>file. QuarkXPress itself has Xerces implemented in Avenue (to handle XML
>douments).
>
>I use Xerces in the following way:
>
>-- BEGIN -----
>...
>XMLPlatformUtils::Initialize();
>SAX2XMLReader* pXMLParser = XMLReaderFactory::createXMLReader();
>
>pXMLParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
>pXMLParser->setFeature(XMLUni::fgXercesDynamic, true);
>
>pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);          //
>Processing namespace enabled
>pXMLParser->setFeature(XMLUni::fgXercesSchema, true);                //
>Processing schema enabled
>pXMLParser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);   // Full
>schema constraint checking processing disabled
>pXMLParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, false);  //
>pXMLParser->Namespace-prefixes feature disabled
>
>// Content- and Errorhandler
>int errorCount = 0;
>int errorCode = 0;
>try {
>   CGenerateFromXMLHandler oHandler(m_iProcess, m_sXMLFile);     // my handler
>   pXMLParser->setContentHandler(&oHandler);
>   pXMLParser->setErrorHandler(&oHandler);
>#if MACOS
>   pXMLParser->parse(sXMLFile.c_str());
>#else
>   pXMLParser->parse(m_sXMLFile.c_str());
>#endif
>   errorCount = pXMLParser->getErrorCount();
>   delete pXMLParser;
>}
>XMLPlatformUtils::Terminate();
>...
>-- END -------
>
>This code is called in a loop for different XML files, this means
>"XMLPlatformUtils::Initialize();", "SAX2XMLReader* pXMLParser =
>XMLReaderFactory::createXMLReader();" and "XMLPlatformUtils::Terminate();"
>are called one time for every run in the loop.
>
>During the parsing a QuarkXPress document is opened, boxes and text is set
>and so on. Different API functions of the QuarkXPress XDK for the
>development of XTensions are used for that.
>
>The problem is that QuarkXPress crashs sooner or later with an "access fault
>exception" (memory) if I do that on this way. Sometimes it works, sometimes
>not. Sometimes I can parse the XML files, but if I repeat the same test it
>crashs. It seems to be a problem with Xerces, but I have no idea what the
>problem could be. I have tested my code for memory problems but it seems to
>be OK. I also comment out some code pieces in my XTension, but XPress crashs
>anyway (on another place of the code). When I comment out the Xerces part in
>my XTension it works, no crash. But of course I can do that only for
>testing, I need Xerces in my Xtension.
>
>- Is there maybe a problem if I call "XMLPlatformUtils::Initialize();" and
>"XMLPlatformUtils::Terminate();" again and agin?
>- Is there maybe a problem if QuarkXPress itself call one of this methods (I
>don't know if it is so)?
>- Maybe a memory problem?
>- Is there a generally problem in Mac OS X 10.3.9 with Xerces?
>- Maybe a problem in my code?
>
>I have tried the same with Xerces 2.7, but it is the same problem.
>
>Thanks for any help and support.
>
>Best regards
>Hans Stössel
>--
>View this message in context: 
>http://www.nabble.com/MAC-OS-X-10.3.9---Quark-6.5-XTension---Xerces-2.1%3A-QuarkXPress-crashs-tf2805928.html#a7828432
>Sent from the Xerces - C - Users mailing list archive at Nabble.com.