bugGNU Octave - Bugs: bug #62587, __FILE__ crashes the interpreter


bug #62587: __FILE__ crashes the interpreter

Submitter:  None
Submitted:  Sun 05 Jun 2022 08:02:10 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Eduardo Pellini Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 7.1.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Thu 09 Jun 2022 02:47:07 PM UTC, comment #12: 

If a BIST consists of only a single `assert` statement, it is more concise to use the `%!assert` syntax for it.
I made that change here (and also moved the new BISTs to lex.ll because after reconsidering I think they match even better in that file):

Markus Mützel <mmuetzel>
Group administrator
Thu 09 Jun 2022 01:16:32 PM UTC, comment #11: 

Thanks, Markus. I pushed it here: https://hg.savannah.gnu.org/hgweb/octave/rev/4dbd8d999b9e

Only after pushing did I realize I made a typo in the bug number in the commit message (I wrote 52587 instead of 62587). Facepalm.

Arun Giridhar <arungiridhar>
Group Member
Thu 09 Jun 2022 06:52:09 AM UTC, comment #10: 

@Arun: In general, more tests are a good thing. But it is probably not necessary to add this as a fixed test. Instead, you could add these tests to `oct-parse.yy`. Maybe close to the test that checks that keywords can't be used as variable names:

Maybe also separate them into two BISTs (starting with `%!assert <*62587>`) to make it easier to pinpoint which command it is in case they should start to fail at some point.

Markus Mützel <mmuetzel>
Group administrator
Wed 08 Jun 2022 08:58:00 PM UTC, comment #9: 

This works properly for me now. Do we need to add a BIST like in comment #5?

Arun Giridhar <arungiridhar>
Group Member
Tue 07 Jun 2022 12:11:20 PM UTC, comment #8: 

The same change needed to be made in a number of places in the base_lexer::make_keyword_token function.  I pushed my change here:


I did not merge stable to default because a previous change has some merge conflicts that I'm not sure how to resolve.

John W. Eaton <jwe>
Group administrator
Mon 06 Jun 2022 01:42:31 PM UTC, comment #7: 

Thank you, jwe. That patch works for me too. Updating status.

Arun Giridhar <arungiridhar>
Group Member
Mon 06 Jun 2022 04:12:47 AM UTC, comment #6: 

The attached change appears to fix the problem for me.  I can check in a proper changeset tomorrow.

(file #53279)

John W. Eaton <jwe>
Group administrator
Mon 06 Jun 2022 01:50:19 AM UTC, comment #5: 

A possible BIST is attached as a Mercurial diff.

Note: As of now, this BIST will crash the interpreter, even when marked as a known bug, and cause "make check" to exit with an error.

(file #53278)

Arun Giridhar <arungiridhar>
Group Member
Mon 06 Jun 2022 01:14:24 AM UTC, comment #4: 

Found it. It was this revision: https://hg.savannah.gnu.org/hgweb/octave/rev/a001811a68e6

Paging jwe.

Bisection trail:

30904:04120d65778a    ## 7.1.0, known crash,     Apr 2022
29655:32f4357ac8d9    ## 6.xx, found to be good, May 2021
30145:cd6f7957c889    ## crash  2021 Sep 09
29924:aeba7278cf80    ## good   2021 Jul 28
30036:80373844f8b2    ## good   2021 Aug 24
30090:1575b324613d    ## good   2021 Aug 31
30118:d809b99f1280    ## good   2021 Sep 05
30131:a471bf0f78ba    ## good   2021 Sep 04
30138:2dca5c25237d    ## good   2021 Sep 08 10:46 UTC
30141:58f043641a78    ## crash  2021 Sep 08 23:02 UTC
30139:c789e728d57a    ## good   2021 Sep 08 15:14 UTC
30140:a001811a68e6    ## crash  2021 Sep 08 21:35 UTC

The first bad revision is:
changeset:   30140:a001811a68e6
summary:     use parser functions to build parse tree objects in grammar rule actions

Arun Giridhar <arungiridhar>
Group Member
Sun 05 Jun 2022 09:00:16 PM UTC, comment #3: 

A plain call to _FILE_ and _LINE_ on 6.4.0 give the following:

octave:1> __FILE__
ans = stdin
octave:2> __LINE__
ans = 1

Both those cause panic_impossible on 7.1.0 and 8.

Arun Giridhar <arungiridhar>
Group Member
Sun 05 Jun 2022 08:48:34 PM UTC, comment #2: 

Same thing happens with _LINE_. Even though it doesn't make sense with fileparts, it should at least give an error without crashing.

On 6.4.0:

octave:1> [a,b,c] = fileparts(__LINE__)
error: fileparts: FILENAME must be a single string
error: called from
    fileparts at line 42 column 5

On 7.1.0:

octave:1> [a,b,c] = fileparts (__LINE__)
panic: impossible state reached in file '/home/jwe/src/octave-stable/libinterp/parse-tree/oct-parse.yy' at line 2878
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

Arun Giridhar <arungiridhar>
Group Member
Sun 05 Jun 2022 08:29:56 PM UTC, comment #1: 

I can reproduce this crash on Linux. Changing OS to Any and status to Confirmed.

On Octave 6.4.0:

octave:1> [a,b,c] = fileparts (__FILE__)
a =
b = stdin
c =

On Octave 7.1.0:

octave:1> [a,b,c] = fileparts (__FILE__)
panic: impossible state reached in file '/home/jwe/src/octave-stable/libinterp/parse-tree/oct-parse.yy' at line 2878
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

On Octave 8:

octave:1> [a,b,c] = fileparts (__FILE__)
panic: impossible state reached in file '../libinterp/parse-tree/oct-parse.yy' at line 2878
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

Arun Giridhar <arungiridhar>
Group Member
Sun 05 Jun 2022 08:02:10 PM UTC, original submission:  

Dear friends,

Some (rock solid) scripts i had written in the past started to fail after upgrade to Octave 7.1.0.

After a lot of 'hide and seek' activities, trying to understand if the problem was related to some kind of character encoding wars, I found that a single call (I used it for years) to get the current script location and name, was crashing the entire interpreter!

It`s easy to reproduce, simply typing...

[ScriptDir, ScriptName, ScriptExt] = fileparts (_FILE_);

... and everything falls apart.

The single call to the keyword _FILE_ in the interpreter is crashing everything! The GUI exits without any error message.

Running from command prompt I found the following information:

octave:1> _FILE_
panic: impossible state reached in file '/home/jwe/src/octave-stable/libinterp/parse-tree/oct-parse.yy' at line 2878
fatal: caught signal Aborted -- stopping myself...

My workaround today is to use:
[ScriptDir, ScriptName, ScriptExt] = fileparts(mfilename('fullpath'));

I'm a brazilian user, using Windows 10 (in portuguese pt-br). I always change my interface language to 'en_us', and the editor character encoding to 'utf-8' to avoid problems. I don't guess this is a problem related to these adjustments.

I guess the problem is somewhat related to some underlying file system function. Other bug reports describes something wrong with dir() function as well. I think the problems are related.

I'm available to supply any further information you need.

Keep up the good work!
Eduardo Pellini



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

Attach Files:

Attached Files
file #53279:  line-file-token-diffs.txt added by jwe (1KiB - text/plain)
file #53278:  fileline.patch added by arungiridhar (2KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by arungiridhar
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by None (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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-09 arungiridhar StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2022-06-07 jwe StatusPatch Submitted Ready For Test
    2022-06-06 arungiridhar StatusConfirmed Patch Submitted
    2022-06-06 jwe Attached File- Added line-file-token-diffs.txt, #53279
    2022-06-06 arungiridhar Item GroupSegfault, Bus Error, etc. Regression
    2022-06-06 arungiridhar Attached File- Added fileline.patch, #53278
    2022-06-06 arungiridhar Item GroupNone Segfault, Bus Error, etc.
    2022-06-06 arungiridhar Carbon-Copy- Added jwe
    2022-06-05 arungiridhar StatusNone Confirmed
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code