xmlsec / python-xmlsec

Python bindings for the XML Security Library.
MIT License
95 stars 99 forks source link

lxml 5.0.0 incompatibility - Arithmetic exception #277

Closed eljeffeg closed 8 months ago

eljeffeg commented 10 months ago

lxml 5.0.0 was released on Dec 29th 2023. This update causes an Arithmetic exception (core dumped) when using python-xmlsec.

Example code that would fail..

import xmlsec
from lxml import etree
root = None
with open("sign4-in.xml") as f:
    root = etree.parse(f).getroot()
xmlsec.tree.add_ids(root, ["ID"])
brianray commented 10 months ago

also experiencing segfault with lxml-5

nosnilmot commented 10 months ago

Use pip install --no-binary lxml lxml to install lxml from source and link to system libxml2, same as xmlsec, to avoid conflicting libxml2 libraries. See also https://bugs.launchpad.net/lxml/+bug/1960668#yui_3_10_3_1_1705879387759_1639 and https://github.com/nosnilmot/lxml/blob/master/doc/FAQ.txt#L623

eljeffeg commented 9 months ago

@nosnilmot Sucks that your PR from Dec 2022 was never accepted. We could have avoided the entire issue. Suggest upvoting a fork. lol https://github.com/xmlsec/python-xmlsec/issues/275

bgaifullin commented 8 months ago

I am not sure, that need to build lxml from source every-time.

nosnilmot commented 8 months ago

I am not sure, that need to build lxml from source every-time.

what are you not sure about?

lxml bundles it's own copy of libxml2 which may be a different version from the library that xmlsec is linked against, the only way to ensure they are both using the same version is to rebuild lxml.

This is documented here: https://lxml.de/FAQ.html#my-application-crashes

deronnax commented 8 months ago

@eljeffeg you are on macOS, aren't you?

eljeffeg commented 8 months ago

Yes, I'll try and test it tonight or tomorrow.

eljeffeg commented 8 months ago

@deronnax I can confirm I was able to build the latest xmlsec on MacOS and it passed the example code posted in the issue description.