FS#75274 - [lhapdf] Segmentation fault when using the python interface of LHAPDF.

Attached to Project: Community Packages
Opened by JumaX9 (jumax9) - Friday, 08 July 2022, 16:40 GMT
Last edited by Konstantin Gizdov (kgizdov) - Friday, 19 August 2022, 11:51 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Konstantin Gizdov (kgizdov)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

When trying to get an array of results from LHAPDF I'm getting a segmentation fault.

I've installed the package (version 6.5.1) from source and it works as expected (snippet to reproduce the error below) so it must (I guess?) be a problem of the arch package. I've reverted back to 6.4 and it works as expected as well.

Additional info:
version: 6.5.1


* link to upstream bug report, if any

Steps to reproduce:


Python example that reproduces the error:

```
from lhapdf import mkPDF
import numpy as np
xarr = np.arange(0, 50)/50
qarr = np.ones_like(xarr)*1.65
aa = mkPDF("NNPDF40_nnlo_as_01180")
aa.xfxQ([21, 5, 4], xarr, qarr)
```

which should return an array of 50 values.

and the error:

/usr/include/c++/12.1.0/bits/stl_vector.h:1142: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = double; _Alloc = std::allocator<double>; const_reference = const double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
This task depends upon

Closed by  Konstantin Gizdov (kgizdov)
Friday, 19 August 2022, 11:51 GMT
Reason for closing:  Fixed
Additional comments about closing:  lhapdf 6.5.2-3
Comment by Konstantin Gizdov (kgizdov) - Thursday, 18 August 2022, 10:21 GMT
Is this still an issue with lhapdf 6.5.2-1?
Comment by JumaX9 (jumax9) - Thursday, 18 August 2022, 10:54 GMT
With 6.5.2 the python interface doesn't work:

import lhapdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/lhapdf/__init__.py", line 1, in <module>
from .lhapdf import *
ModuleNotFoundError: No module named 'lhapdf.lhapdf'

(but this might be an upstream problem?)
Comment by Konstantin Gizdov (kgizdov) - Thursday, 18 August 2022, 15:21 GMT
lhapdf 6.5.2-2 should fix that. For some reason, some esoteric flag needed to be specified. Definitely an upstream issue.
Comment by JumaX9 (jumax9) - Friday, 19 August 2022, 00:55 GMT
  • Field changed: Percent Complete (100% → 0%)
The original bug is not fixed though. The python example in the OP is still producing the same segmentation fault for me with 6.5.2
Comment by Toolybird (Toolybird) - Friday, 19 August 2022, 00:59 GMT
Can repro and of course it's the python process crashing. gdb anyone?
Comment by Konstantin Gizdov (kgizdov) - Friday, 19 August 2022, 11:51 GMT
I am pretty sure this is an upstream problem with the PDF. The error is visible because now, on Arch, we ask for _GLIBCXX_ASSERTIONS to be defined. I am guessing the PDF or how it was generated introduces a bug, and GCC cannot satisfy the assertion about a vector it was given and its correct size. That is potentially a buffer overflow since the error is caused by a vector with elements beyond its defined size. I have switched the assertions checker for the moment, but this should be reported upstream, and that PDF could lead to memory corruption.

lhapdf 6.5.2-3 no longer has the problem.

Loading...