Closed 1oly closed 8 months ago
The @inbounds
here seems fishy:
https://github.com/JuliaDSP/DSP.jl/blob/42634c097f22f8b48b822a144b6734df9e569552/src/Filters/stream_filt.jl#L635
Removing it, I get
julia> X = resample(y,rate)
ERROR: BoundsError: attempt to access 1920000-element Array{Float64,1} at index [1920001]
Stacktrace:
[1] setindex! at ./array.jl:767 [inlined]
[2] filt!(::Array{Float64,1}, ::FIRFilter{DSP.Filters.FIRArbitrary{Float64}}, ::Array{Float64,1}) at DSP/src/Filters/stream_filt.jl:635
[3] filt(::FIRFilter{DSP.Filters.FIRArbitrary{Float64}}, ::Array{Float64,1}) at DSP/src/Filters/stream_filt.jl:648
[4] resample(::Array{Float64,1}, ::Float64, ::Array{Float64,1}) at DSP/src/Filters/stream_filt.jl:703
[5] resample(::Array{Float64,1}, ::Float64) at DSP/src/Filters/stream_filt.jl:708
[6] top-level scope at none:0
There's two issues here:
filt!
should not assume buffer
to be of sufficient size. If we keep the @inbounds
, we need to verify before the loop.buffer
should have been allocated with (at least) the required size. I'm not quite into the resampling machinery, though, so I don't know where/how to fix this.Thanks for the quick reply and for tracking down the issue to @inbounds
. Been looking a bit more and found this line:
https://github.com/JuliaDSP/DSP.jl/blob/42634c097f22f8b48b822a144b6734df9e569552/src/Filters/stream_filt.jl#L365 from this commit: https://github.com/JuliaDSP/DSP.jl/commit/6a4e6d3fe5aa08d738aa3060099b8517252e25af
Looks like this has been an issue before since tests were disabled and I do get different results for inputlength
for Arbitrary or Rational here : https://github.com/JuliaDSP/DSP.jl/blob/42634c097f22f8b48b822a144b6734df9e569552/src/Filters/stream_filt.jl#L699
@1oly #272 should hopefully fix the segfaults, but not address the underlying problem. However, using master should produce more useful errors. Please let us know if you get any more insight into what is causing these errors.
Thanks for addressing the segfault. Will get back if I find the culprit...
Closing in favour of #317
Hello,
I'm getting a segmentation fault for resample when
rate
is a certain float value (example coming from an actual script wheres
andy
are audio signals):by using Rational type, I don't see a segmentation fault:
I tried to look in
resample_filter
https://github.com/JuliaDSP/DSP.jl/blob/270e6f25de3f9176493c3bfed863bf0ec94289ac/src/Filters/design.jl#L606 but cannot reproduce manually.Will be happy to help out if this is not an issue on my side.
Thanks!
Error:
and versioninfo:
and Pkg.status: