Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:02:42+00:00 2026-06-13T09:02:42+00:00

I am using Libxml2 to read/write XML files. For catching libxml errors while loading

  • 0

I am using Libxml2 to read/write XML files.
For catching libxml errors while loading XML, i am using xmlSetGenericErrorFunc.

void Myclass::load(const std::string &filename)
{
    xmlGenericErrorFunc handler = (xmlGenericErrorFunc) catchErrors;
    xmlSetGenericErrorFunc(this, handler); //context pointer, error handler
}

Resetting the context and error handler can be done as below.

xmlSetGenericErrorFunc(NULL, NULL); 

My wrapper library is used by many processes.
Libxml2 is a .so file.

If i use context pointer in error handler, will there be any probability for a crash if some process dies without resetting the context pointer and parsing error occurs in other process ? can libxml invoke error callback with a dead pointer ?

Any help would be appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:02:43+00:00Added an answer on June 13, 2026 at 9:02 am

    After having a look at the source:

    First check if libxml is compiled with LIBXML_THREAD_ENABLED. You may check with xmllint -version and it should say: compiled with: Threads ...

    xmlSetGenericErrorFunc (from error.c) sets xmlGenericError (defined in globals.h), which (in case threads are enabled) is declared as part of xmlGlobalState structure.

    Now the xmlGetGlobalState documentation states clearly that the state is maintained for each thread separately.

    So theoretically threads don’t influence one another and you should observe that setting error handler in one thread doesn’t change the behaviour of another thread. And it seems you’re on the safe side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a generic XML to Core Data parser using libxml2. Since
I am trying to read tags from XML using LibXML. I can print all
I am using libxml-ruby gem to read a xml string. I am unable to
I am trying to write a xml parser in C using the libxml2 on
I am use libxml2 for XML parsing. The sample code on the libxml website
I am trying to parse an XML file using the SAX interface of libxml2
I've recently came across a very interesting inconsistency while using libxml++ (a C++ wrapper
I'm using libxml2 with libxslt for XML processing from a C++ program. For transforming
I am parsing xml file by using libxml2.0, the code is below here. I
I am using the libxml2 libraries to parse XML sent to me (my program)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.