Hi folks,
I've run into an odd situation which I hope someone might be able to
shed some light upon.
I have a library using Xerces-C. This works on multiple platforms, and
works fine. Yesterday, I added initial support for Xalan-C. This
appears to work on all platforms, except for one (FreeBSD with xerces-c3
and xalan-c from ports). Both are compiled without ICU support.
$ ldd /usr/local/lib/libxerces-c.so
/usr/local/lib/libxerces-c.so:
libthr.so.3 => /lib/libthr.so.3 (0x8019c0000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x801be4000)
libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x801ea3000)
libm.so.5 => /lib/libm.so.5 (0x8020bf000)
libc.so.7 => /lib/libc.so.7 (0x800821000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x8022e8000)
$ ldd /usr/local/lib/libxalan-c.so
/usr/local/lib/libxalan-c.so:
libm.so.5 => /lib/libm.so.5 (0x801b15000)
libxerces-c-3.1.so => /usr/local/lib/libxerces-c-3.1.so
(0x801e00000)
libxalanMsg.so => /usr/local/lib/libxalanMsg.so (0x8023c0000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x8025c8000)
libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x802887000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x802aa3000)
libc.so.7 => /lib/libc.so.7 (0x800821000)
libthr.so.3 => /lib/libthr.so.3 (0x802cb1000)
My unit test here fails with "invalid document structure". However, the
XML is well-formed UTF-8 with no BOM; it's been working fine for years.
The difference between the exception being thrown or not thrown is very
simple: whether or not I link Xerces-C (works) or Xerces-C *and* Xalan-C
(fails). I'm not *using* Xalan-C, I'm merely linking my shared library
against it.
What I don't understand is why xercesc::AbstractDOMParser::parse would
be affected by linking Xalan-C into my library. Does it have some
dynamically-registered hooks which subtly alter the behaviour of
Xerces-C? There's no visible presence of Xalan in the stacktrace below,
but it's clearly had *some* effect. If I remove Xalan from the linker
options, it works immediately.
Another data point: If I build Xerces-C from source on the same
platform, linking against ICU, it works with Xalan-C built from source
(without ICU). Is there some required combination to get a functional
setup? The other platforms also had Xerces compiled against ICU. Or
any way to configure things to make it work?
Kind regards,
Roger
(gdb) run
Starting program: /tmp/ome-common-cpp/b/test/ome-common/xerces
[==========] Running 80 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 80 tests from XercesVariants/XercesTest
[ RUN ] XercesVariants/XercesTest.Node/0
[ OK ] XercesVariants/XercesTest.Node/0 (7 ms)
[ RUN ] XercesVariants/XercesTest.Node/1
Fatal Error at file "streambuf", line 1, column 1
Message: invalid document structure
[New Thread 807406400 (LWP 101339)]
[Switching to Thread 807406400 (LWP 101339)]
Catchpoint 1 (exception thrown), 0x000000080390c3c4 in __cxa_throw ()
from /lib/libcxxrt.so.1
(gdb) bt
#0 0x000000080390c3c4 in __cxa_throw () from /lib/libcxxrt.so.1
#1 0x0000000802ddfaf7 in
xercesc_3_1::XMLScanner::emitError(xercesc_3_1::XMLErrs::Codes) () from
/usr/local/lib/libxerces-c-3.1.so
#2 0x0000000802ddf81d in xercesc_3_1::XMLScanner::scanProlog() () from
/usr/local/lib/libxerces-c-3.1.so
#3 0x0000000802db62dd in
xercesc_3_1::IGXMLScanner::scanDocument(xercesc_3_1::InputSource const&)
() from /usr/local/lib/libxerces-c-3.1.so
#4 0x0000000802dfc834 in
xercesc_3_1::AbstractDOMParser::parse(xercesc_3_1::InputSource const&)
() from /usr/local/lib/libxerces-c-3.1.so
#5 0x00000008008ff37c in (anonymous
namespace)::read_source(xercesc_3_1::XercesDOMParser&,
ome::common::xml::EntityResolver&, xercesc_3_1::InputSource&) () from
/tmp/ome-common-cpp/b/lib/ome/common/libome-common.so.5.2.0
#6 0x00000008008ffea0 in
ome::common::xml::dom::createDocument(std::__1::basic_istream<char,
std::__1::char_traits<char> >&, ome::common::xml::EntityResolver&,
ome::common::xml::dom::ParseParameters const&,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > const&) () from
/tmp/ome-common-cpp/b/lib/ome/common/libome-common.so.5.2.0
#7 0x00000008008dc48b in
ome::common::xml::EntityResolver::registerCatalog(boost::filesystem::path
const&) ()
from /tmp/ome-common-cpp/b/lib/ome/common/libome-common.so.5.2.0
#8 0x00000000004278dd in XercesTest::SetUp() ()
#9 0x00000008031f9ad4 in void
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
void>(testing::Test*, void (testing::Test::*)(), char const*) () from
/usr/local/lib/libgtest.so.0
#10 0x00000008031e330b in testing::Test::Run() () from
/usr/local/lib/libgtest.so.0
#11 0x00000008031e43c4 in testing::TestInfo::Run() () from
/usr/local/lib/libgtest.so.0
#12 0x00000008031e4c20 in testing::TestCase::Run() () from
/usr/local/lib/libgtest.so.0
#13 0x00000008031ec467 in testing::internal::UnitTestImpl::RunAllTests()
() from /usr/local/lib/libgtest.so.0
#14 0x00000008031fa784 in bool
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool>(testing::internal::UnitTestImpl*, bool
(testing::internal::UnitTestImpl::*)(), char const*) () from
/usr/local/lib/libgtest.so.0
#15 0x00000008031ec0f6 in testing::UnitTest::Run() () from
/usr/local/lib/libgtest.so.0
#16 0x0000000000444641 in RUN_ALL_TESTS() ()
#17 0x0000000000444485 in main ()