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 Stephen Torri <st...@torri.org> on 2006/10/03 05:25:49 UTC
Segfault with XMLString
I am not sure why I am getting a segfault in the XMLString::transcode
function. Since I am new to Xerces I worked to produce a test program
that shows the error here on my system. This program was compiled with
GCC-4.1 and Xerces-c 2.7.0 on a Gentoo system. The segfault occurs at
the line in the Configuration_Tag_Names.cpp constructor:
TAG_PASSWORD ( XMLString::transcode ( "password" ) )
Any help is appreciated.
Stephen
---------- backtrace from GDB ---------------------
#0 0xb7dbcdc0 in xercesc_2_7::XMLString::transcode ()
from /usr/lib/libxerces-c.so.27
#1 0x08048e02 in Configuration_Tag_Names (this=0xbfaacf94)
at Configuration_Tag_Names.cpp:17
#2 0x08048ac8 in main () at test_configuration_tag_names.cpp:7
-------------------- CODE --------------------------
#include "Configuration_Tag_Names.hpp"
using namespace libreverse::infrastructure;
int main (int, char** )
{
Configuration_Tag_Names ctn;
}
#ifndef CONFIGURATION_TAG_NAMES_H
#define CONFIGURATION_TAG_NAMES_H
#include <xercesc/util/XercesDefs.hpp>
using namespace xercesc;
namespace libreverse {
namespace infrastructure {
class Configuration_Tag_Names {
public:
XMLCh* TAG_TRANSFER_TYPE;
XMLCh* TAG_FORMULA_DIRECTORY;
XMLCh* TAG_FILE_PREFIX;
XMLCh* TAG_DATABASE;
XMLCh* TAG_MEMORY;
XMLCh* TAG_HOST;
XMLCh* TAG_USER;
XMLCh* TAG_PASSWORD;
Configuration_Tag_Names ();
~Configuration_Tag_Names() throw ();
};
} /* namespace infrastructure */
} /* namespace libreverse */
#endif /* CONFIGURATION_TAG_NAMES_H */
#include "Configuration_Tag_Names.hpp"
#include <xercesc/util/XMLString.hpp>
#include <exception>
#include <iostream>
namespace libreverse {
namespace infrastructure {
Configuration_Tag_Names::Configuration_Tag_Names ()
: TAG_TRANSFER_TYPE ( XMLString::transcode ( "transfer_type" ) ),
TAG_FORMULA_DIRECTORY ( XMLString::transcode ( "formula_directory" ) ),
TAG_FILE_PREFIX ( XMLString::transcode ( "file_prefix" ) ),
TAG_DATABASE ( XMLString::transcode ( "database" ) ),
TAG_MEMORY ( XMLString::transcode ( "memory" ) ),
TAG_HOST ( XMLString::transcode ( "host" ) ),
TAG_USER ( XMLString::transcode ( "user" ) ),
TAG_PASSWORD ( XMLString::transcode ( "password" ) )
{}
Configuration_Tag_Names::~Configuration_Tag_Names() throw ()
{
try {
XMLString::release ( &TAG_TRANSFER_TYPE );
XMLString::release ( &TAG_FORMULA_DIRECTORY );
XMLString::release ( &TAG_FILE_PREFIX );
XMLString::release ( &TAG_DATABASE );
XMLString::release ( &TAG_MEMORY );
XMLString::release ( &TAG_HOST );
XMLString::release ( &TAG_USER );
XMLString::release ( &TAG_PASSWORD );
}
catch ( std::exception& e ) {
std::cerr << "Exception: " << e.what() << std::endl;
}
}
} /* namespace infrastructure */
} /* namespace libreverse */
Re: Segfault with XMLString
Posted by Alberto Massari <am...@datadirect.com>.
Hi Stephen,
you are missing the XMLPlatform::initialize call: see
http://xml.apache.org/xerces-c/faq-build.html#faq-12
Alberto
At 22.25 02/10/2006 -0500, Stephen Torri wrote:
>I am not sure why I am getting a segfault in the XMLString::transcode
>function. Since I am new to Xerces I worked to produce a test program
>that shows the error here on my system. This program was compiled with
>GCC-4.1 and Xerces-c 2.7.0 on a Gentoo system. The segfault occurs at
>the line in the Configuration_Tag_Names.cpp constructor:
>
> TAG_PASSWORD ( XMLString::transcode ( "password" ) )
>
>Any help is appreciated.
>
>Stephen
>
>---------- backtrace from GDB ---------------------
>
>#0 0xb7dbcdc0 in xercesc_2_7::XMLString::transcode ()
> from /usr/lib/libxerces-c.so.27
>#1 0x08048e02 in Configuration_Tag_Names (this=0xbfaacf94)
> at Configuration_Tag_Names.cpp:17
>#2 0x08048ac8 in main () at test_configuration_tag_names.cpp:7
>
>-------------------- CODE --------------------------
>#include "Configuration_Tag_Names.hpp"
>
>using namespace libreverse::infrastructure;
>
>int main (int, char** )
>{
> Configuration_Tag_Names ctn;
>}
>
>#ifndef CONFIGURATION_TAG_NAMES_H
>#define CONFIGURATION_TAG_NAMES_H
>
>#include <xercesc/util/XercesDefs.hpp>
>
>using namespace xercesc;
>
>namespace libreverse {
>namespace infrastructure {
>
> class Configuration_Tag_Names {
> public:
> XMLCh* TAG_TRANSFER_TYPE;
> XMLCh* TAG_FORMULA_DIRECTORY;
> XMLCh* TAG_FILE_PREFIX;
> XMLCh* TAG_DATABASE;
> XMLCh* TAG_MEMORY;
> XMLCh* TAG_HOST;
> XMLCh* TAG_USER;
> XMLCh* TAG_PASSWORD;
>
> Configuration_Tag_Names ();
>
> ~Configuration_Tag_Names() throw ();
> };
>
>} /* namespace infrastructure */
>} /* namespace libreverse */
>
>#endif /* CONFIGURATION_TAG_NAMES_H */
>
>#include "Configuration_Tag_Names.hpp"
>#include <xercesc/util/XMLString.hpp>
>#include <exception>
>#include <iostream>
>
>namespace libreverse {
>namespace infrastructure {
>
> Configuration_Tag_Names::Configuration_Tag_Names ()
> : TAG_TRANSFER_TYPE ( XMLString::transcode ( "transfer_type" ) ),
> TAG_FORMULA_DIRECTORY ( XMLString::transcode (
> "formula_directory" ) ),
> TAG_FILE_PREFIX ( XMLString::transcode ( "file_prefix" ) ),
> TAG_DATABASE ( XMLString::transcode ( "database" ) ),
> TAG_MEMORY ( XMLString::transcode ( "memory" ) ),
> TAG_HOST ( XMLString::transcode ( "host" ) ),
> TAG_USER ( XMLString::transcode ( "user" ) ),
> TAG_PASSWORD ( XMLString::transcode ( "password" ) )
> {}
>
> Configuration_Tag_Names::~Configuration_Tag_Names() throw ()
> {
> try {
> XMLString::release ( &TAG_TRANSFER_TYPE );
> XMLString::release ( &TAG_FORMULA_DIRECTORY );
> XMLString::release ( &TAG_FILE_PREFIX );
> XMLString::release ( &TAG_DATABASE );
> XMLString::release ( &TAG_MEMORY );
> XMLString::release ( &TAG_HOST );
> XMLString::release ( &TAG_USER );
> XMLString::release ( &TAG_PASSWORD );
> }
> catch ( std::exception& e ) {
> std::cerr << "Exception: " << e.what() << std::endl;
> }
> }
>
>} /* namespace infrastructure */
>} /* namespace libreverse */