Re: segfault on xpath queries :P

darryl <[email protected]> Tue, 11 May 2004 13:46:53 -0500
Newsgroups gmane.comp.web.syncato.general
Message-ID <[email protected]>
darryl wrote:
> darryl wrote:
> 
>> darryl wrote:
>>
>>> darryl wrote:
>>>
>>>> darryl wrote:
>>>>
>>>>>
>>>>>>>
>>>>>>> Ok... well, I ended up using all client-side xslt & xpath for the 
>>>>>>> demo I had to do on Saturday. I will try to do some more 
>>>>>>> debugging, but since I can't reproduce this behaviour when I'm 
>>>>>>> driving libxml directly, I may just start using the libraries 
>>>>>>> themselves.
>>>>>>> -- 
>>>>>>>
>>>>>> It's unfortunate but it appears Kimbro is otherwise occupied. I 
>>>>>> looked, but dont' know the code well enough to do some serious 
>>>>>> debugging.
>>>>>> Hopefully you can see something in your debugging attempts.
>>>>>>
>>>>>> cheers,
>>>>>> darryl
>>>>>>
>>>>> FWIW, i don't know shit about debugging python extension modules in 
>>>>> python BUT when i ran python under gdb and ran the script i got:
>>>>>  >>> from Weblog import Weblog
>>>>>  >>> blog = Weblog('.')
>>>>> Registering prefix syncato
>>>>>  >>> blog.handleRequest('//character','','','')
>>>>>
>>>>> Program received signal SIGSEGV, Segmentation fault.
>>>>> [Switching to Thread 16384 (LWP 6013)]
>>>>> 0x40d49980 in xmlReconciliateNs () from /usr/lib/libxml2.so.2
>>>>> (gdb)
>>>>>
>>>>>
>>>>> -darryl
>>>>>
>>>>
>>>> It seems to by crashing on this function call:
>>>>
>>>> result.reconciliateNs(doc.getDocument())
>>>>
>>>> It also seems to only affect 501.xml,503.xml and 504.xml
>>>>
>>>> -darryl
>>>>
>>>
>>> I commented out the above function call and it parses all your 
>>> documents fine. I have no idea what affect that will have, but there 
>>> you go...
>>>
>>>
>>> -darryl
>>>
>> Ok this is getting fun now:
>>
>>  >import libxml2
>>  >doc = libxml2.parseFile('501.xml')
>>  >results = doc.xpathEval('//character')
>>  >for result in results:
>> ...  result.reconciliateNs(doc)
>> ...
>> Segmentation fault
>>
>> So it appears it's not syncato's fault.
>> FWIW it's breaking on this:
>>
>> <character name="Ferraguto">Ferrag&ugrave;</character>
>>
>> It doesn't appear to like the "&ugrave;"
>> -darryl
> 
> 
> If you escape(?) the <character>Ferrag&ugrave;</character>
> to
> <character>Ferrag&amp;ugrave;</character>
> It seems to work fine. I, of course, have no idea
> what you are trying to do....
> 
> ~darryl

And for hopefully my final comment:

If you set:

libxml2.substituteEntitiesDefault(1)

all is golden....

Help on function substituteEntitiesDefault in module libxml2:

substituteEntitiesDefault(val)
     Set and return the previous value for default entity
     support. Initially the parser always keep entity
     references instead of substituting entity values in the
     output. This function has to be used to change the default
     parser behavior SAX::substituteEntities() has to be used
     for changing that on a file by file basis.

~darryl
-- 
http://randomthoughts.vandorp.ca/WK/blog


-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3