Re: [libxml++] SIGABRT received during xmlpp::Document::write_to_string_formatted
- From: Cyril PICARD <cyril picard-mail laposte net>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] SIGABRT received during xmlpp::Document::write_to_string_formatted
- Date: Tue, 11 Jan 2005 20:59:52 +0100
Jonathan Wakely wrote:
On Mon, Jan 10, 2005 at 10:27:09PM +0100, Cyril PICARD wrote:
Hi
I'm writing an XML file with the xmlpp interface.
Everything is fine with xmlpp::Document::write_to_file_formatted();
But when I'm calling xmlpp::Document::write_to_string_formatted(), I
receive a SIGABRT signal.
Any idea around ?
Thanks
I'll have a guess ...
* gdb info st :
#0 0x403aa621 in kill () from /lib/libc.so.6
#1 0x4017826b in raise (sig=6) at signals.c:65
#2 0x403aba53 in abort () from /lib/libc.so.6
#3 0x402f7895 in __cxxabiv1::__terminate(void (*)()) () from
/usr/lib/libstdc++.so.3
#4 0x402f7880 in __cxxabiv1::__terminate(void (*)()) () from
/usr/lib/libstdc++.so.3
#5 0x402f79e0 in __cxa_rethrow () from /usr/lib/libstdc++.so.3
#6 0x402ede29 in std::__throw_length_error(char const*) () from
/usr/lib/libstdc++.so.3
#7 0x0804aef1 in std::string::_Rep::_S_create(unsigned,
std::allocator<char> const&) (__capacity=4294967295,
__alloc= 0xbffff500) at /usr/include/g++-v3/bits/basic_string.tcc:371
#8 0x0804ab28 in char* std::string::_S_construct<char const*>(char
const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) (
__beg=0x80516e0 "<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>\n<!DOCTYPE GEDCOM SYSTEM
\"gedcom60.dtd\">\n<!--Generated by libgedcomparser - part of GHOSTS
project-->\n<GEDCOM>blah ?</GEDCOM>\n", __end=0x80516df "",
__a= 0xbffff500) at /usr/include/g++-v3/bits/basic_string.tcc:143
The frame above has __end < __beg, which is why an exception is thrown.
#9 0x40034674 in std::string::string(char const*, unsigned,
std::allocator<char> const&) (this=0xbffff560,
__s=0x80516e0 "<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>\n<!DOCTYPE GEDCOM SYSTEM
\"gedcom60.dtd\">\n<!--Generated by libgedcomparser - part of GHOSTS
project-->\n<GEDCOM>blah ?</GEDCOM>\n", __n=4294967295,
__a= 0xbffff500) at /usr/include/g++-v3/bits/basic_string.h:666
That seems to be because __n = std::string::npos = size_t(-1) in frame #9,
which must be passed by:
#10 0x401c40c4 in Glib::ustring::ustring(char const*, unsigned)
(this=0xbffff560,
src=0x80516e0 "<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>\n<!DOCTYPE GEDCOM SYSTEM
\"gedcom60.dtd\">\n<!--Generated by libgedcomparser - part of GHOSTS
project-->\n<GEDCOM>blah ?</GEDCOM>\n", n=169)
at /usr/include/g++-v3/bits/stl_alloc.h:571
n = 169 in that frame, but Glib::ustring seems to pass -1 to the
std::string ctor. That looks as though utf8_byte_offset(src,n) returns
-1, which I think means there was an invalid UTF8 character in the
string. Is the data you pass to the string correctly UTF8-encoded?
The gdb output shows the '�' wasn't converted from latin1 to utf-8.
#11 0x40025d27 in xmlpp::Document::do_write_to_string(Glib::ustring
const&, bool) (this=0xbffff6a0,
encoding= 0xbffff5d0, format=true) at document.cc:309
jon
Thanks jon
I understand your comments, but I don't understand how to correctly
UTF-8-encode my string. I thought my conversion was ok since
- I use the ConvertInput function provided in the libxml2 code samples
- I successfully write the xml data into a file using
Document::write_to_file_formatted
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]