bugGNU Octave - Bugs: bug #43640, mkoctfile -M infinite loop on arm64

 
 

bug #43640: mkoctfile -M infinite loop on arm64

Submitter:  Rafael Laboissière <rlaboiss>
Submitted:  Wed 19 Nov 2014 10:03:17 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.2 Operating System:  * Other
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 02 Dec 2014 10:45:23 AM UTC, comment #2: 

Dear Sébastien and Edmund,
thank you for your patch. I've pushed to stable with cset 7759e4d62f04 (http://hg.savannah.gnu.org/hgweb/octave/rev/7759e4d62f04)

Closing as fixed.

Andreas Weber <andy1978>
Group Member
Mon 01 Dec 2014 08:48:28 PM UTC, comment #1: 

I confirm this issue. Actually it affects all architectures where char is unsigned (which means ARM, PowerPC and several other less popular platforms in Debian).

On those archs, since char is unsigned, in function get_line of src/mkoctfile.in.cc, "c" can never be equal to EOF (because EOF is -1). Hence the infinite loop.

I attach the patch that I applied to the Debian package.

(file #32580)

Sébastien Villemot <svillemot>
Wed 19 Nov 2014 10:03:17 PM UTC, original submission:  

I am hereby forwarding a bug report filed by Edmund Grimley Evans against the Debian package octave.  The bug is claimed to happen on the arm64 architecture.  I did not test it in the said architecture.  The full report is here:

https://bugs.debian.org/770192

The reporter wrote, essentially this:

[snip]

On arm64 mkoctfile -M goes into an infinite loop:


echo > t.c
mkoctfile -M t.c
# it runs for ever


This may be because of this code in src/mkoctfile.in.cc:


get_line (FILE *fp)
{
  static std::vector<char> buf (100);
  unsigned int idx = 0;
  char c;

  while (true)
    {
      c = static_cast<char> (gnulib::fgetc (fp));
      if (c == '\n' || c == EOF)
        break;


On architectures where plain char is unsigned, c == EOF will always be false. Just use:


  int c;

  while (true)
    {
      c = gnulib::fgetc (fp);


Rafael Laboissière <rlaboiss>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #32580:  mkoctfile-infinite-loop.patch added by svillemot (783B - text/x-diff - Patch applied in Debian)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by svillemot (Updated the item)
  • -email is unavailable- added by rlaboiss (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-12-02 andy1978 StatusNone Fixed
        Open/ClosedOpen Closed
    2014-12-01 svillemot Attached File- Added mkoctfile-infinite-loop.patch, #32580

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code