bugGNU Octave - Bugs: bug #45092, lexer panic from syntax error in...

 
 

bug #45092: lexer panic from syntax error in M-file

Submitter:  Andreas Weber <andy1978>
Submitted:  Wed 13 May 2015 08:37:19 AM UTC
   
 
Category:  Interpreter Severity:  4 - Important
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 14 May 2015 09:14:18 AM UTC, comment #8: 

Thanks. Closing report

Andreas Weber <andy1978>
Group Member
Thu 14 May 2015 08:13:55 AM UTC, comment #7: 

I checked in this second changeset.  Ultimately, I think the fix was really just to remove the assert.

http://hg.savannah.gnu.org/hgweb/octave/rev/e679dc89e64b

John W. Eaton <jwe>
Group administrator
Wed 13 May 2015 09:13:27 PM UTC, comment #6: 

Sorry, my change was probably made to hastily.  I don't know what I was thinking, but yeah, keywords should probably be allowed as structure field names.  Fixing that will require a little more refactoring so that the is_keyword_token function doesn't set the at_beginning_of_statement flag.  I'll fix this, but it will probably not happen until later tonight or tomorrow.

John W. Eaton <jwe>
Group administrator
Wed 13 May 2015 08:57:05 PM UTC, comment #5: 

According to the documentation for functions()


    *Warning:* `functions' is provided for debugging purposes only.
     It's behavior may change in the future and programs should not
     depend on a particular output.


So the quick and obvious thing to do would be to change the field name to something that is not 'function'.  In fact, I think this would be clearer.  Again, according to the documentation,


 -- Built-in Function: S = functions (FCN_HANDLE)
     Return a structure containing information about the function handle
     FCN_HANDLE.

     The structure S always contains these three fields:

    function
          The function name.  For an anonymous function (no name) this
          will be the actual function definition.


I propose using a field called 'fcnname' or 'name' or 'fcn_name' or maybe 'fname' but that last one looks like filename.

Rik <rik5>
Group administrator
Wed 13 May 2015 07:52:27 PM UTC, comment #4: 

After this C'set the initial problem is solved but now test ov-fcn-handle.cc-tst fails (fntests.log at the end).

The problem is this example code

functions(@transpose).function


which now fails with

>> functions(@transpose).function
error: structure fields may not be keywords
parse error:

  syntax error

>>> functions(@transpose).function


Reopening bugreport.

fntests.log:

>>>>> processing /home/andy/src/octave-stable-build/libinterp/octave-value/ov-fcn-handle.cc-tst
***** test
 x = {".**", "power";
      ".'", "transpose";
      ".+", "plus";
      ".-", "minus";
      ".*", "times";
      "./", "rdivide";
      ".^", "power";
      ".\\", "ldivide";
      "<=", "le";
      "==", "eq";
      ">=", "ge";
      "~=", "ne";
      "!=", "ne";
      "**", "mpower";
      "~", "not";
      "!", "not";
      "\'", "ctranspose";
      "+", "plus";
      "-", "minus";
      "*", "mtimes";
      "/", "mrdivide";
      "^", "mpower";
      "\\", "mldivide";
      "<", "lt";
      ">", "gt";
      "&", "and";
      "|", "or"};
 for i = 1:rows (x)
   assert (functions (str2func (x{i,1})).function, x{i,2});
 endfor
!!!!! test failed
structure fields may not be keywords


Andreas Weber <andy1978>
Group Member
Wed 13 May 2015 07:39:26 PM UTC, comment #3: 

Fixed.  Closing report.

Rik <rik5>
Group administrator
Wed 13 May 2015 06:21:37 PM UTC, comment #2: 

I checked in the following changeset.

http://hg.savannah.gnu.org/hgweb/octave/rev/f185653b2f5e

John W. Eaton <jwe>
Group administrator
Wed 13 May 2015 03:06:17 PM UTC, comment #1: 

Confirmed.

I changed the Severity from Minor to Important because the parser should never segfault, even for unexpected or badly formatted input.

Rik <rik5>
Group administrator
Wed 13 May 2015 08:37:19 AM UTC, original submission:  

hg id 2ae4a7ef4378

create a file foo.m

function myfunction ()
  if (r.
# this comment is important
endfunction


and run 'foo' from Octave gives


ctave:str-to-num: ../../octave/libinterp/parse-tree/lex.ll:2910: int octave_base_lexer::handle_identifier(): Assertion `! at_beginning_of_statement' failed.
panic: Aborted -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Abgebrochen


I stumbled over this because "lookfor" parses all m-files in the current working directory and stops with the above error because there is unfinished code in some files.

Andreas Weber <andy1978>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by andy1978 (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-05-14 andy1978 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-05-13 andy1978 StatusFixed Ready For Test
        Open/ClosedClosed Open
    2015-05-13 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-05-13 rik5 Severity2 - Minor 4 - Important
        StatusNone Confirmed
    2015-05-13 rik5 Carbon-Copy- Added jwe

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code