[xml] thread saftey and xmlXPathEvalExpression



Hello.
I have the following multi thread related problem.

main(){
xmlInitParser();
//validationstuff
xmlParserCtxtPtr globalContext = xmlSchemaValidCtxtGetParserCtxt(ctxt);
}

threadFunction(){
xPathObjectPtr foos = xmlXPathEvalExpression ("foo", globalContext);
//read all the foos
}
(sorry I dont have the actual code here)

The program makes a lot of new threads and some of these segfault if there are to many of them. So e.g. when I create 50 threads, approx. 10 of them segfault - the rest don't.

I first thought, I could fix this by using a globalDocPtr instead of context and create a new context in each thread - but this will lead to the segfaults.

I could reduce the problem to the xmlXPathEvalExpression call (since if I return before, everything wents fine). Did I use the API wrong or what is the problem (at least as you can say based on the piece of code)?

Regards,
Oliver


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