You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test suite segfault on Linux/x86_64/Python 3.7 with old GCC #12483
In the conda-forge project, we see a segfault in the test suite when building scikit-learn packages against Python 3.7 using an older GCC. Here is the related issue report.
The bit involving a memmap seems to me like it could potentially be fragile, but I see that there are other tests with the same flag that succeed.
Running in a debugger, I don't have any debug symbols, but the backtrace lands in scipy:
(gdb) bt
#0 0x00007fffcc189f3e in pdist_euclidean_double_wrap ()
from /a/TEMP37/lib/python3.7/site-packages/scipy/spatial/_distance_wrap.cpython-37m-x86_64-linux-gnu.so
#1 0x0000000000431f3d in cfunction_call_varargs ()
#2 0x0000000000431fee in PyCFunction_Call ()
#3 0x00000000004ef5df in do_call_core ()
(Then the backtrace continues for many frames inside the Python interpreter.)
We do not see this failure on other versions of Python, or when building with GCC7, or on macOS.
I can upload the Conda package made out of the build that exhibits this problem, but since it doesn't have debugging symbols I think it would be a challenge to do much investigation with it.
likely related to memmap=True. This is 0.20.0 release right? not any branch or something. We had one of these before. We're probably trying to write to a memmapped array.
For what it's worth, in my detailed debugging there were other tests that had readonly_mmap=True that passed without segfaulting. And the tests pass for other platforms, Python versions, and compiler versions. But perhaps for this particular build environment and this particular algorithm, something subtle gets triggered that causes the generated code to try to write to the array.
FWIW here is the C code in SciPy 1.1.0, which is responsible for defining pdist_euclidean_double_wrap (along with various other pdist functions all double precision).
It appears to be happening during a call to scipy.cluster.hierarchy.ward in ward_treehere. At this point the scipy ward function gets as input a (51, 2) array with the following array.flags,
However saving this array and providing it to ward in read-only mode (by opening the data as mmap) does not segfault. Maybe it's due to to the fact that the array is a slice of a larger array (and so I'm not sure what happens with alignment). I have not investigated further.
In any case using np.require(something, requirements="W") does fix it (or using O or A flags as in either case a copy is triggered I imagine).
Activity
amueller commentedon Oct 29, 2018
likely related to memmap=True. This is 0.20.0 release right? not any branch or something. We had one of these before. We're probably trying to write to a memmapped array.
amueller commentedon Oct 29, 2018
Makes me think of #11133. Maybe check if doing
np.require(something, requirements="W")like in #11133 helps.Is this deterministic?
pkgw commentedon Oct 29, 2018
Yes, 0.20.0. Yes, deterministic.
For what it's worth, in my detailed debugging there were other tests that had
readonly_mmap=Truethat passed without segfaulting. And the tests pass for other platforms, Python versions, and compiler versions. But perhaps for this particular build environment and this particular algorithm, something subtle gets triggered that causes the generated code to try to write to the array.jakirkham commentedon Oct 29, 2018
FWIW here is the C code in SciPy 1.1.0, which is responsible for defining
pdist_euclidean_double_wrap(along with various otherpdistfunctions alldoubleprecision).Edit: The underlying computation is here.
rth commentedon Oct 29, 2018
I can also reproduce this with the
condaforge/linux-anvilDocker image and the following setup,Details
It appears to be happening during a call to
scipy.cluster.hierarchy.wardinward_treehere. At this point the scipywardfunction gets as input a(51, 2)array with the followingarray.flags,However saving this array and providing it to
wardin read-only mode (by opening the data as mmap) does not segfault. Maybe it's due to to the fact that the array is a slice of a larger array (and so I'm not sure what happens with alignment). I have not investigated further.In any case using
np.require(something, requirements="W")does fix it (or usingOorAflags as in either case a copy is triggered I imagine).Fix proposed in #12485
I have not tried to reproduce this on master, but I think it would still apply.
amueller commentedon Oct 30, 2018
I don't understand why this is platform specific but better safe than sorry?
jakirkham commentedon Oct 30, 2018
Think it is compiler specific (not platform specific). Using a newer version of GCC on Linux fixes the issue.
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (#…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…
[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps (s…