Re: [xml] memory tag error occurs



--- $BldsUL (B <nuanfeng m2 sys to casio co jp> wrote:
hello everyone
I used libxmls to parse part of xml  content in memory.but the error
information of " memory tag error occurs:00f7be0  bye" was put out.
how can I deal with it,

Not sure if this is related but I recently tracked down some problems around
the debug memory handlers.  In my case the following were true:
* libxml2 was compiled without threads support
* libxml2 was using the supplied memory debug handlers (xmlMemAlloc,
xmlMemFree, etc.)
* libxml2 experienced 'random' crashes in xmlFree

It turned out the problem in my case was that I was using libxml2 in a
multi-threaded environment.  I thought I didn't need thread support because any
of the globals (those replaced with thread safe equivalents when compiled in)
were never changed, and a single thread never accessed/changed (xmlFree'd, etc)
data created by a different thread.

There was one area that i missed.  When using the libxml2 memory routines
(which are very good at finding leaks) a linked list of allocated blocks used
(MEM_LIST).  Whenever something is xmlMemAlloc'ed, xmlMemFree'ed, etc the
specific block is removed from the linked list.  Multiple threads manipulating
the MEM_LIST were not synchornized, which would lead to either corrupt memory
link list and segfaults. 

Morale of the story:  if you have multiple threads and use the debug memory
handlers you must compile libxml2 with threads support.  Not sure if this is
your problem but hopefully others learn from my mistake.




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