falcong / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

xml_document.load() #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I ran Valgrind on an application that I am working on. The xml_document is 
instantiated with a XML document that is I hold in a char array on heap. 
Valgrind reports the following:

==19570== Thread 4:
==19570== Conditional jump or move depends on uninitialised value(s)
==19570==    at 0x4C25E38: strlen (in 
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==19570==    by 0x41F159: (anonymous namespace)::strlength(char const*) 
(pugixml.cpp:123)
==19570==    by 0x425AAE: pugi::xml_document::load(char const*, unsigned) 
(pugixml.cpp:4596)
==19570==    by 0x4057B7: GetEventFromXMLFile(std::string) (tmcd.cpp:51)

The XML file is parsed correctly, so I guess this is either not related to 
pugixml or just of cosmetic nature.

I used pugixml 1.0 and g++ 4.3.

Original issue reported on code.google.com by dennis.l...@gmail.com on 7 Dec 2010 at 5:14

GoogleCodeExporter commented 9 years ago
Hmm, this should not be happening, and should not be pugixml related either.
Can you please check that it is not by adding strlen(data.c_str()) call (where 
data is your string) before calling xml_document::load()? Valgrind should 
report the strlen call as a problem.

It is possible that strlen on your target platform is optimized by reading 
4-byte or even 16-byte chunks; this is safe, as long as the code is correct - 
i.e. stops at first zero in branching decisions - but it would trigger valgrind 
error.

Original comment by arseny.k...@gmail.com on 7 Dec 2010 at 5:19

GoogleCodeExporter commented 9 years ago
You were right. The strlen() just before xml_document::load() showed that the 
problem is related to the char* containing the UTF8 encoded string. Thanks!

Original comment by dennis.l...@gmail.com on 8 Dec 2010 at 7:30

GoogleCodeExporter commented 9 years ago

Original comment by arseny.k...@gmail.com on 9 Dec 2010 at 5:16