svenpeter42 / fastfilters

Old academic project for my PhD - no longer maintained by me: fast gaussian and derivative convolutional filters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segmentation fault during fir_convolve_impl_mirror_mirror_antisymmetric_avxfmaN

ssidorenko opened this issue · comments

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: 1f8d11a

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.

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.

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.

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?

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

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.