[xml] race conditions in libxml2
- From: Hovnatan Karapetyan <hovnatan gmail com>
- To: xml gnome org
- Subject: [xml] race conditions in libxml2
- Date: Tue, 1 Dec 2015 00:40:08 +0400
Hi,
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) {
xmlFreeDoc(doc);
}
void* test2(void* ptr) {
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` should be thread safe. I'm compiling with `gcc -I/usr/include/libxml2 temp.c -lxml2 -pthread`.
Thanks,
Hovnatan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]