You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by si...@free.fr on 2007/12/11 15:15:52 UTC

XalanTransformer::initialize throws an exception

Hi,
My program uses xerces-2.7.0 and xalan-c-1.10. It performs a loop calling
successively:
XMLPlatformUtils::Initialize();
XalanTransformer::initialize();

// some code

XalanTransformer::terminate();
XMLPlatformUtils::Terminate();

The 1rst loop is ok, but it cores at the second one.

Thanks for your help
Simon

gdb output:
--------------
(gdb) where
#0  0x04f66ef1 in kill () from /lib/libc.so.6
#1  0x043a5bb1 in pthread_kill () from /lib/libpthread.so.0
#2  0x043a5f2b in raise () from /lib/libpthread.so.0
#3  0x04f66b24 in raise () from /lib/libc.so.6
#4  0x04f683fd in abort () from /lib/libc.so.6
#5  0x050f3954 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
#6  0x050f3991 in std::terminate () from /usr/lib/libstdc++.so.5
#7  0x050f3ec8 in __cxa_pure_virtual () from /usr/lib/libstdc++.so.5
#8  0x04dc5856 in xalanc_1_10::XalanCopyConstruct<xalanc_1_10::FunctionCurrent>
() from /usr/local/lib/libxalan-c.so.110
#9  0x04dc5634 in xalanc_1_10::FunctionCurrent::clone () from
/usr/local/lib/libxalan-c.so.110
#10 0x04d20e14 in xalanc_1_10::XPathFunctionTable::InstallFunction () from
/usr/local/lib/libxalan-c.so.110
#11 0x04e462ae in xalanc_1_10::XSLTEngineImpl::installFunctions () from
/usr/local/lib/libxalan-c.so.110
#12 0x04e4a24c in xalanc_1_10::XSLTEngineImpl::initialize () from
/usr/local/lib/libxalan-c.so.110
#13 0x04e53812 in xalanc_1_10::XSLTInit::initialize () from
/usr/local/lib/libxalan-c.so.110
#14 0x04e53a6e in xalanc_1_10::XSLTInit::XSLTInit () from
/usr/local/lib/libxalan-c.so.110
#15 0x04e53c10 in xalanc_1_10::XSLTInit::create () from
/usr/local/lib/libxalan-c.so.110
#16 0x04e76205 in xalanc_1_10::XalanTransformer::initialize () from
/usr/local/lib/libxalan-c.so.110
#17 0x043529bc in Export (this=0x5470038, a_type_proc_id=4, a_action_id=16,
a_table_name=@0xbeb3cf90, a_aTransaction=0xbeb3d290, a_pclConnection=0x51f9658)
    at Export.cpp:63
#18 0x043131f5 in Engine::ProcessFunction (this=0xbeb3d240, customer_id=19592,
action_id=16, function_id=8, a_table_name=@0xbeb3d15c,
    aTransaction=0xbeb3d290) at Engine.cpp:464
#19 0x04314666 in Engine::AchieveRollbackActions (this=0xbeb3d240,
a_aTransaction=0xbeb3d290) at Engine.cpp:312
#20 0x04397eb3 in AdamaRollback::StartServer (this=0xbeb3d324) at
AdamaRollback.cpp:92
#21 0x04398703 in main () at AdamaRollback.cpp:130
#22 0x04f53469 in __libc_start_main () from /lib/libc.so.6
#23 0x08048601 in _start () at ../sysdeps/i386/elf/start.S:119

valgrind output:
-----------------

==9191== Invalid read of size 4
==9191==    at 0x4DC584A: xalanc_1_10::FunctionCurrent*
xalanc_1_10::XalanCopyConstruct<xalanc_1_10::FunctionCurrent>(xercesc_2_7::MemoryManager&,
xalanc_1_10::FunctionCurrent const&) (in /usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4DC5633:
xalanc_1_10::FunctionCurrent::clone(xercesc_2_7::MemoryManager&) const (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4D20E13:
xalanc_1_10::XPathFunctionTable::InstallFunction(unsigned short const*,
xalanc_1_10::Function const&) (in /usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E462AD:
xalanc_1_10::XSLTEngineImpl::installFunctions(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E4A24B:
xalanc_1_10::XSLTEngineImpl::initialize(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E53811:
xalanc_1_10::XSLTInit::initialize(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E53A6D:
xalanc_1_10::XSLTInit::XSLTInit(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E53C0F:
xalanc_1_10::XSLTInit::create(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x4E76204:
xalanc_1_10::XalanTransformer::initialize(xercesc_2_7::MemoryManager&) (in
/usr/local/lib/libxalan-c.so.110.0)
==9191==    by 0x43529BB: Export::Export(int, int, std::string,
pqxx::transaction<(pqxx::isolation_level)0>*,
pqxx::basic_connection<pqxx::connect_direct>*) (Export.cpp:63)
==9191==    by 0x43131F4: Engine::ProcessFunction(int, int, int, std::string,
pqxx::transaction<(pqxx::isolation_level)0>*) (Engine.cpp:464)
==9191==    by 0x4314665:
Engine::AchieveRollbackActions(pqxx::transaction<(pqxx::isolation_level)0>*)
(Engine.cpp:312)
==9191==  Address 0x5251C38 is 0 bytes inside a block of size 4 free'd
==9191==    at 0x401BEC1: operator delete(void*) (vg_replace_malloc.c:244)
==9191==    by 0x45CAEBA: xercesc_2_7::MemoryManagerImpl::~MemoryManagerImpl()
(in /home/simon/software/xerces-c-src_2_7_0/lib/libxerces-c.so.27.0)
==9191==    by 0x45DA75A: xercesc_2_7::XMLPlatformUtils::Terminate() (in
/home/simon/software/xerces-c-src_2_7_0/lib/libxerces-c.so.27.0)
==9191==    by 0x43521E6: Export::~Export() (Export.cpp:106)
==9191==    by 0x430BA2A: Engine::LastProcess() (Engine.cpp:497)
==9191==    by 0x4314735:
Engine::AchieveRollbackActions(pqxx::transaction<(pqxx::isolation_level)0>*)
(Engine.cpp:314)
==9191==    by 0x4397EB2: AdamaRollback::StartServer() (AdamaRollback.cpp:92)
==9191==    by 0x4398702: main (AdamaRollback.cpp:130)


Re: XalanTransformer::initialize throws an exception

Posted by David Bertoni <db...@apache.org>.
simon.elbaz@free.fr wrote:
> Hi,
> My program uses xerces-2.7.0 and xalan-c-1.10. It performs a loop calling
> successively:
> XMLPlatformUtils::Initialize();
> XalanTransformer::initialize();
> 
> // some code
> 
> XalanTransformer::terminate();
> XMLPlatformUtils::Terminate();
> 
> The 1rst loop is ok, but it cores at the second one.

This is not supported.  The comments on XalanTransformer::initialize() and 
XalanTransformer:terminate() make this clear:

     /**
      * Initialize Xalan.
      *
      * Should be called only once per process before creating any
      * instances of XalanTransformer.  This call is not thread-safe,
      * so you must serialize any calls to it, and you must track the
      * initialization state, so you do not call it more than once.
      */
     static void
     initialize(MemoryManager&   theManager = 
XalanMemMgrs::getDefaultXercesMemMgr());

     /**
      * Terminate Xalan.
      *
      * Should be called only once per process after deleting all
      * instances of XalanTransformer.  This call is not thread-safe,
      * so you must serialize any calls to it, and you must track the
      * initialization state, so you do not call it more than once.
      *
      * This is handy when using leak-detection software, as all
      * static data allocated by Xalan is freed.
      *
      */
     static void
     terminate();

The comments in header files are there to help you use the library 
properly, so you should really consider reading them.

Also, you certainly don't want to to these operations in a loop, as they 
are _extremely_ expensive.  They are meant to be called on a per-process basis.

Dave