I have the following pretty simple program:
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <libxml/parser.h>
#include <libxml/catalog.h>
#include <libxml/tree.h>
#include <libxml/HTMLparser.h>
static const int kHTMLParseFlags =
HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR |
HTML_PARSE_NOWARNING | HTML_PARSE_NONET;
void* test1(void* ptr) {
htmlDocPtr doc = htmlReadFile("http://www.google.com", NULL,
kHTMLParseFlags);
xmlFreeDoc(doc);
}
void* test2(void* ptr) {
htmlDocPtr doc = htmlReadFile("http://www.lenta.ru", NULL,
kHTMLParseFlags);
xmlFreeDoc(doc);
}
int main(void)
{
xmlInitParser();
xmlInitializeCatalog();
pthread_t thread1, thread2;
pthread_create(&thread1, NULL, &test1, NULL);
pthread_create(&thread2, NULL, &test2, NULL);
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
xmlCatalogCleanup();
xmlCleanupParser();
return EXIT_SUCCESS;
}
When I run it in `valgrind --tool=helgrind` it shows many race conditions.
What is the reason for this? It seems that `libxml2` is thread safe. I'm
compiling with `gcc -I/usr/include/libxml2 temp.c -lxml2 -pthread`.
Thanks,
Hovnatan
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users