[Pkg-octave-devel] Bug#567975: Bug#567975: FP error when filtering an empty vector

Thomas Weber thomas.weber.mail at gmail.com
Tue Feb 2 09:09:06 UTC 2010


On Tue, Feb 02, 2010 at 01:26:41AM -0500, John W. Eaton wrote:
> On  1-Feb-2010, Bas Zoetekouw wrote:
> 
> | Octave crashes when trying to filter() an empty vector:
> | 
> | | octave:1> a=1; b=ones(10,1)/10; foo=filter(b,a,[]);
> | | panic: Floating point exception -- stopping myself...
> | | attempting to save variables to `octave-core'...
> | | save to `octave-core' complete
> | | zsh: floating point exception  octave
> | 
> | and I'm dropped back into the shell...
> | 
> | Of course, filtering an empty vector doesnt make much sense, but it certainly
> | shouldn't cause a crash.
> | FWIT, Matlab simple returns an empty vector.
> | 
> | -- System Information:
> | Debian Release: 5.0.4
> |   APT prefers stable
> |   APT policy: (500, 'stable')
> | Architecture: amd64 (x86_64)
> | 
> | Kernel: Linux 2.6.26-2-amd64 (SMP w/1 CPU core)
> | Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
> | Shell: /bin/sh linked to /bin/bash
> 
> I checked in the following change:
> 
>   http://hg.savannah.gnu.org/hgweb/octave/rev/a277ba5da4dc
> 
> I'm not sure this fix places the return in exactly the right
> location.  Should it be later in the function, after other dimension
> checks?  It would be nice if someone who is more familiar with how
> filter is expected to work would comment.
> 
> Also, in the future, please report bugs in Octave itself directly to
> the bug at octave.org mailing list and use the Debian bug reporting
> system for problems specific to the Debian package.

Attached is a test case for this. No changelog entry, I don't think this
warrants one.

	Thomas
-------------- next part --------------
# HG changeset patch
# User Thomas Weber <thomas.weber.mail at gmail.com>
# Date 1265101668 -3600
# Node ID 4f93c55f6382906a7cdddff35a5b72b1c957bab2
# Parent  4ea0bda308b7e79bcc69eb7b7703a2151843abee
Add test case for empty argument in filter()

diff --git a/src/DLD-FUNCTIONS/filter.cc b/src/DLD-FUNCTIONS/filter.cc
--- a/src/DLD-FUNCTIONS/filter.cc
+++ b/src/DLD-FUNCTIONS/filter.cc
@@ -735,6 +735,12 @@
 %!  y0 = zeros(4,4,2); y0(1:2,1:4,1) = +1; y0(1:2,1:4,2) = -1;
 %!  y = filter(b, [1], x);
 %!  assert(all(all(all(y==y0))))
+%!
+%!test % test for empty X
+%! a = 1; b = ones(10,1)/10; 
+%! result = filter(b,a,[]);
+%! expected = [];
+%! assert(result, expected);
 
 %%  Should put some tests of the "DIM" parameter in here.
 


More information about the Pkg-octave-devel mailing list