Re: [libxml++] program crashes when parsing XML with accent



Hi,


I could reproduce the problem with the saxparser example and the xml sample file from the bugzilla ticket.
I obtain this bt:

#0  0x403b91b1 in kill () from /lib/libc.so.6
#1  0x4014a9c1 in pthread_kill () from /lib/libpthread.so.0
#2  0x4014accb in raise () from /lib/libpthread.so.0
#3  0x403b8df4 in raise () from /lib/libc.so.6
#4  0x403ba5a8 in abort () from /lib/libc.so.6
#5  0x402bca74 in __cxa_call_unexpected () from /usr/lib/./libstdc++.so.5
#6  0x402bcab1 in std::terminate () from /usr/lib/./libstdc++.so.5
#7  0x402bcc21 in __cxa_throw () from /usr/lib/./libstdc++.so.5
#8  0x40276a5c in std::__throw_length_error () from /usr/lib/./libstdc++.so.5
#9  0x402af83f in std::string::_Rep::_S_create () from /usr/lib/./libstdc++.so.5
#10 0x402b03a4 in std::string::_M_replace_safe<char const*> () from /usr/lib/./libstdc++.so.5
#11 0x402ad23a in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string () from /usr/lib/./libstdc++.so.5
#12 0x401d28b4 in Glib::ustring::ustring () from /usr/lib/./libglibmm-2.3.so.2
#13 0x40024924 in xmlpp::SaxParserCallback::characters (context=0x0, ch=0xbffff0a0 "égal", len=5) at saxparser.cc:390
#14 0x4005dd0d in xmlParseCharDataComplex () from /usr/lib/./libxml2.so.2
#15 0x4005d7d2 in xmlParseCharData () from /usr/lib/./libxml2.so.2
#16 0x40066bf1 in xmlParseContent () from /usr/lib/./libxml2.so.2
#17 0x40066fa9 in xmlParseElement () from /usr/lib/./libxml2.so.2
#18 0x400682e3 in xmlParseDocument () from /usr/lib/./libxml2.so.2
#19 0x4002383d in xmlpp::SaxParser::parse (this=0xbffff560) at saxparser.cc:152
#20 0x4002398a in xmlpp::SaxParser::parse_file (this=0xbffff560, filename= 0xbffff590) at saxparser.cc:173
#21 0x08049adc in main (argc=2, argv=0x0) at main.cc:45

We see at line #13 that the callback gives the string utf-8 encoded and it's length in characters. This is with no doubt correct, and those values are given to ustring constructor directly.

Going throught ustring sources I see that the constructor we use do this:
   269 ustring::ustring(const char* src, ustring::size_type n)
   270 :
   271   string_ (src, utf8_byte_offset(src, n))
   272 {}

knowing that std::__throw_length_error () is supposed to be raised if size is greater than max_size, I presume utf8_byte_offset returned std::string::npos.

My probably stupid question is the following:
Murray, in ustring::ustring(const char* src, ustring::size_type n), is "n" supposed to be the length in utf-8 characters, or in bytes ?


Regards,

Christophe






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]