Repository navigation
Segmentation fault on xmlsec.tree.add_ids() in Python Development Mode #259
Description
Activity
I checked whether this is an lxml <-> xmlsec issue, but it is not:
$ pip install --no-binary :all: --force-reinstall lxml $ PYTHONDEVMODE=1 python boom.py (...) Segmentation fault
Hello just had a similar problem with xmlsec.tree.add_ids
program crash on this line without any error message
I solve the issue by falling back to lxml==4.9.3 instead of lxml==5.1.0Brgds JL
Reacted by Wonjae Hwang, Eduard Maghakyan, NESIC) Naoya Kato, Patrick Dobson, Maylin Jeong, Petros Anagnou, Jake Lester, Enrique Matías Sánchez, AndPena, Yaroslav and 6 moreReacted by Jake Lester, Yaroslav and Simon Wei(位西朋)Reacted by Petros Anagnou, Rhenan, Jake Lester, AndPena, Yaroslav, chyok and Simon Wei(位西朋)@jlthorel You saved my life...!! 👍
This fixed a problem for me too. It was causing a SAML SSO login failure for me. Has anyone submitted a bug to lxml? Their bug tracker is here: https://launchpad.net/lxml
@jlthorel You saved my life as well..! 💯
@jlthorel thank you for saving us as well! You are the best!!!
We had issues recently with SSO on heroku where our ACS was failing. We isolated it to python3-samlvalidate_sign--> xmlsecxmlsec.tree.add_ids(elem, ["ID"])... thank you ❤️@jlthorel You saved my life!!
We had the same issue with our SAML SSO failing due to a seg fault, downgrading
lxmlresolved the issueHello just had a similar problem with xmlsec.tree.add_ids program crash on this line without any error message I solve the issue by falling back to lxml==4.9.3 instead of lxml==5.1.0
OMG, this was driving me crazy: my SAML SSO was failing most of the times, but sometimes it did work 😠 .
Downgrading xml fixed the issue :-) Thanks a lot for the tip!!!This fixed a problem for me too. It was causing a SAML SSO login failure for me. Has anyone submitted a bug to lxml? Their bug tracker is here: https://launchpad.net/lxml
I couldn't find any bug report about this, so I just submitted one:
https://bugs.launchpad.net/lxml/+bug/2054606Hello just had a similar problem with xmlsec.tree.add_ids program crash on this line without any error message I solve the issue by falling back to lxml==4.9.3 instead of lxml==5.1.0
Brgds JL
Thank you very much! This solution worked for me too.
This fixed a problem for me too. It was causing a SAML SSO login failure for me. Has anyone submitted a bug to lxml? Their bug tracker is here: https://launchpad.net/lxml
I couldn't find any bug report about this, so I just submitted one: https://bugs.launchpad.net/lxml/+bug/2054606
The folks at lxml closed the report.
They consider it is a third party issue (ie, that the problem lies in xmlsec).I believe commit ee9fbd0 by @jonathangreen avoids the segfault without any error message, and emits instead an exception ("lxml & xmlsec libxml2 library version mismatch").
However, it's still not clear to me what we should do to avoid it.
Hi @quique. My comment here gives some context #316 (comment) that might be helpful.
Basically to avoid the issue, either both
lxmlandxmlsecshould be installed from wheels, or should both be installed with--no-binaryset.The most recent release for
xmlsecsupplies wheels for most platforms, so updating to the most recent and making sure that it it installed from via a wheel is probably the easiest fix.Reacted by Simon Wei(位西朋)@jonathangreen Thank you for your helpful comment!
Unfortunately it seems I'm quite thick today, because I am unable to make it work.
This is what I do:
docker run -it python:3.12-slim-bookworm /bin/bash # Place sign1-res.xml and boom.py inside the container (see the issue report by @Anthchirp ) pip install lxml --only-binary=lxml pip install xmlsec --only-binary=xmlsec PYTHONDEVMODE=1 python boom.py # See it crash
If I understand it correctly, this way both
lxmlandxmlsecare installed from wheels, but I stil get a segmentation fault.
This is what I see:root@d199d2820803:/# pip install lxml --only-binary=lxml Collecting lxml Downloading lxml-5.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (3.4 kB) Downloading lxml-5.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (4.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.9/4.9 MB 7.5 MB/s eta 0:00:00 Installing collected packages: lxml Successfully installed lxml-5.2.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv root@d199d2820803:/# pip install xmlsec --only-binary=xmlsec Collecting xmlsec Downloading xmlsec-1.3.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.3 kB) Requirement already satisfied: lxml>=3.8 in /usr/local/lib/python3.12/site-packages (from xmlsec) (5.2.1) Downloading xmlsec-1.3.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.9/3.9 MB 7.2 MB/s eta 0:00:00 Installing collected packages: xmlsec Successfully installed xmlsec-1.3.14 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv root@d199d2820803:/# python boom.py root@d199d2820803:/# PYTHONDEVMODE=1 python boom.py Debug memory block at address p=0x56499b02ca70: API '!' 6873730420813529088 bytes originally requested The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfd): at p-7: 0x00 *** OUCH at p-6: 0x00 *** OUCH at p-5: 0x00 *** OUCH at p-4: 0x00 *** OUCH at p-3: 0x00 *** OUCH at p-2: 0x00 *** OUCH at p-1: 0x00 *** OUCH Because memory is corrupted at the start, the count of bytes requested may be bogus, and checking the trailing pad bytes may segfault. The 8 pad bytes at tail=0x5f64bbafc965ca70 are Fatal Python error: Segmentation fault Current thread 0x00007fb0f0a63740 (most recent call first): File "//boom.py", line 6 in <module> Extension modules: lxml._elementpath, lxml.etree, xmlsec (total: 3) Segmentation fault (core dumped)
Any hint? Thank you!
Reacted by Facundo Quiroga
boom.py:
with
sign-res.xmlcoming from the xmlsec examples.Expected output
Observed output
Environment
I'm running on Ubuntu 22.04 with system python 3.10.6 and xmlsec 1.3.13.
pip listapt list | grep xmlsec | grep installed