octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54180] libinterp/corefcn/file-io.cc-tst failu


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #54180] libinterp/corefcn/file-io.cc-tst failure and weird output when test suite is run twice
Date: Mon, 25 Jun 2018 03:29:48 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

Follow-up Comment #7, bug #54180 (project octave):

Hey, look at io.tst lines 514 through 537.


%! nm = tempname ();
%! id = fopen (nm, "wb");
%! if (id > 0)
%!   for i = 1:n
%!     fwrite (id, i, type_list{i});
%!   endfor
%!
%!   fclose (id);
%!
%!   id = fopen (nm, "rb");
%!   if (id > 0)
%!     x = zeros (1, n);
%!     for i = 1:n
%!       x(i) = fread (id, [1, 1], type_list{i});
%!     endfor
%!
%!     if (x == 1:n)
%!       __printf_assert__ ("ok\n");
%!     endif
%!   endif
%! endif
%!
%! unlink (nm);
%! assert (__prog_output_assert__ ("ok"));


That `fopen (nm, "rb")` inside the loop looks like a dangling fopen() to me.

And then in lines 576 through 611:


%!test
%! nm = tempname ();
%! id = fopen (nm, "wb");
%! if (id > 0)
%!   fprintf (id, "%d\n", 1:100);
%!   fclose (id);
%!   id = fopen (nm, "rb");
%!   if (id > 0)
%!     for i = 1:101
%!       fgets (id);
%!     endfor
%!     if (feof (id))
%!       fclose (id);
%!       id = fopen (nm, "rb");
%!       pos_one = ftell (id);
%!       s_one = fgets (id);
%!       for i = 1:48
%!         s = fgets (id);
%!       endfor
%!       pos_fifty = ftell (id);
%!       s_fifty = fgets (id);
%!       fseek (id, pos_one, SEEK_SET);
%!       s_one_x = fgets (id);
%!       fseek (id, pos_fifty, SEEK_SET);
%!       s_fifty_x = fgets (id);
%!       if (s_one == s_one_x && s_fifty == s_fifty_x)
%!         frewind (id);
%!         s_one_x = fgets (id);
%!         if (s_one != s_one_x)
%!           error ("bombed!!");
%!         endif
%!       endif
%!     endif
%!   endif
%! endif
%! unlink (nm);


That `id = fopen (nm, "rb");` inside the loop at line 589 doesn't seem to have
a corresponding fclose().

And that would account for the two leaked file descriptors.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54180>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]