svenpeter42 / fastfilters

Old academic project for my PhD - no longer maintained by me: fast gaussian and derivative convolutional filters
MIT License
9 stars 10 forks source link

Segmentation fault during fir_convolve_impl_mirror_mirror_antisymmetric_avxfmaN #13

Closed ssidorenko closed 7 years ago

ssidorenko commented 7 years ago

I've encoutered segmentation faults while running code in a ipython notebook using fastfilters to validate a model to be used in ilastik. I've managed to narrow it down to this minimal case to trigger it:

import fastfilters
import numpy as np

data = np.random.normal(size=(200, 200))
data = fastfilters.hessianOfGaussianEigenvalues(data, window_size=3.5, scale=3.5)
data = fastfilters.structureTensorEigenvalues(data, window_size=3.5, innerScale=3.5, outerScale=3.5)

It seems to occur in fir_convolve_impl_mirror_mirror_antisymmetric_avxfmaN as seen in the crash report attached below.

python3.6_2017-10-10-123502_MacBook-Pro.crash.txt

This was using fastfilters compiled from the latest master at the time of this post: 1f8d11a8bf0651566c18f47bf269792555c6d35f

svenpeter42 commented 7 years ago

Thanks for the detailed report. I've heard about this bug before but so far no one had been able to produce a small testcase!

I'm busy teaching this week but will try to fix it afterwards.

@stuarteberg @k-dominik I think this is the bug we've run into a few times already.

svenpeter42 commented 7 years ago

Running hessianOfGaussianEigenvalues twice also reliably triggers this segfault for me. I think the first call overwrites some memory which triggers the fault in the second call.

ssidorenko commented 7 years ago

Interestingly, using two consecutive hessianOfGaussianEigenvalues but with scale and windowSize set to 1.2 (or lower) does not trigger the segmentation fault.

Compiling with FMA and AVX disabled still gives a segmentation fault.

svenpeter42 commented 7 years ago

I think in this case the problem is that you try to filter the result of an eigenvalue filter again. Fastfilters will assume 3d convolution for the second one and then fault because one axis only has a length of two.

Did you want to do this or is the testcase just coincidentally faulting and the real error is somewhere else?

ssidorenko commented 7 years ago

Indeed, the testcase is coincidentally faulting. I'll try to make another testcase closer to what I wanted to do.

ssidorenko commented 7 years ago

After more investigation, it turns out that the downsampled data I was using for development was too small (3D array with depth of 12 while computing LoG with window_size=4). I think that #14 should then be the only change needed.