Re: [xml] python bindings initialization



On Tue, Jun 29, 2004 at 10:22:35PM +0200, Stéphane Bidoul wrote:
Hi,

The python binding initialization routine 
(initlibxml2mod in python/libxml.c) does
not initialize libxml2 by calling xmlInitParser but
tries to imitate it.

Last time I tried to replace that by xmlInitParser, the memory
debugging in the test suite was complaining. 
This is because in the cleanup, it was deallocating memory 
that had been allocated before the memory debug functions
were put in place.

Today, I've been bit badly by this partial initialization
(xmlInitThreads was not called, and it was quite needed!). 
So I resolved to fix the memory debugging problem.

The solution I suggest is to xmlCleanupParser
in libxml_xmlDebugMemory before setting up
memory debugging malloc and call xmlInitParser again.

That works fine with the test suite.
Can you have a look at the attached patch?

  Yes this sounds like an interesting solution, but ... it
break in my regression tests. Basically I compile with --with-mem-debug
enabled, i.e. all the memory is allocated, from the start, with
the memory debugging shell. Your trick seems to confuse something
somewhere, and all regression tests with python now fail with:
  paphio:~/XML/python/tests -> ./build.py
  Memory leak -422 bytes

I.e. we end-up with a shifted memory count, there is 2 ways to 
solve this:
  - the unclean way: never report negative memory allocated memory
    and reset the base when it happens
  - find out about where that base shift comes from (probably the
    memory allocated with the debug memory routines when running 
    with memory debug - can probably be tested by checking the 
    existing memory routine before switching to debug) and account
    for it when reporting.

I think your trick solves the hardest part for users, but it would be
great if the problem for running the regressions tests in debug mode
could be solved. BTW there is also a serious problem with the debug mode
when running the libxslt python regression tests, the whole set 
(debug + libxml2 + libxslt + python) seems to completely confuse the
memory allocator (I assume it's something similar to the problem you
fixed), but it still happen with your patch in.

I probably won't be able to make the release before this week-end, 
could you have a look at those cornercases if you have time ?

  thanks,

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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