bugGNU Octave - Bugs: bug #52582, Dependent constant properties in...


bug #52582: Dependent constant properties in classdef errors: no such file

Submitted by:  Damian Gisler <zweistein>
Submitted on:  Sun 03 Dec 2017 04:47:55 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Damian Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sun 03 Mar 2019 09:24:00 PM UTC, comment #13:

With the code from comment #8 I can get a segfault simply by trying to create an instance of the class. Looking at a stack trace, the parser is being called recursively while trying to create the meta class object, while evaluating the properties block. There is a comment in the cdef-class.cc file that that is not exactly about this issue, but it seems relevant:

I'm not sure of the details, but it seems we need to do what that comment suggests and register the partially constructed object so that we can use it (at least as much as has been constructed so far) to complete the initialization and fully construct the meta object.

John W. Eaton <jwe>
Project Administrator
Sun 03 Mar 2019 08:15:01 PM UTC, comment #12:

Okay, I an reproduce the "no such file" message if I start with

Rik <rik5>
Project Administrator
Sun 03 Mar 2019 05:09:03 PM UTC, comment #11:

I still get the error message reported in comment #8

Mike Miller <mtmiller>
Project Administrator
Sun 03 Mar 2019 07:03:42 AM UTC, comment #10:

I just tested with changeset 26816:92ecc4a97b5c. I see no crash or error message.

@Rik, that's a strange error to have for this code, since the script has no indexing. I see that "sq_string" using a lot in the ov.cc and "cannot be indexed with" shows up all over the Octave source. My guess at starting point would be that the parser in your case is having trouble trying to look up the structure element name. Perhaps using the '.' of ".c1" to search a variable table?

Dan Sebald <sebald>
Sun 03 Mar 2019 05:29:14 AM UTC, comment #9:

Running on the latest development tip, this still doesn't work, but the error message has change once again.

Adding jwe to the CC list simply because he has been looking at classdef issues lately.

Rik <rik5>
Project Administrator
Tue 27 Nov 2018 03:19:10 AM UTC, comment #8:

An update on this issue (I'm running Octave 4.4.1 on Xubuntu):

Using the given Crash classdef example from this thread:

When I run


from the Octave interpreter, for me Octave does not crash (as Daiman said he observed). Instead I get the following error message:

I guess it's good that it doesn't crash any more, but a fix would be nice. As Philip mentioned, the above works just fine in Matlab.

Travis Arnold <teerav42>
Tue 05 Dec 2017 05:21:07 PM UTC, comment #7:

OK, "which". Yes, I'm seeing that:

It appears someone has filed a bug report related to "type" and classdef (https://savannah.gnu.org/bugs/?52585), so I think that covers most issues at the moment.

Dan Sebald <sebald>
Tue 05 Dec 2017 04:16:22 PM UTC, comment #6:

@Dan: That is what I was trying to say. Whenever a function is used for the first time, regardless of whether it is invoked, queried for help, or the target of the type() function, it is first parsed. If it fails parsing then the overall command fails.

Bug report #50541 explains a bit why which() returns "built-in function" for a classdef file. That doesn't seem right in this case where the function is a user-specified classdef file.

I filed a report about not being ablet to use the help system with classdef keywords here https://savannah.gnu.org/bugs/index.php?52591

Rik <rik5>
Project Administrator
Tue 05 Dec 2017 09:36:05 AM UTC, comment #5:

Octave must be trying to evaluate the expressing before typing out its contents, i.e., Crash() as opposed to Crash.m which must be a file...well, I suppose Crash.m could be a classdef element, ha.

Here, I'm seeing a 2 rather than a 5:

Dan Sebald <sebald>
Mon 04 Dec 2017 11:55:52 PM UTC, comment #4:

The segmentation fault is the same from type () as it is for invoking the file to create an instance of an object. The issue is that the first time Octave needs an m-file, for whatever reason, it parses it. And since this file doesn't parse correctly it causes some sort of error.

I think the other two issues should be opened as independent bug reports. One should be able to say 'type classfile' and have it work. Indeed, this works if you specifically give it the name of the file

The file type.m can be inspected to see what is going on. The problem is that

returns "Built-in Function". All classdef files do this, which is incorrect. There is a bug report about that already.

The second issue, at least minimal help for the "classdef" keyword, is a new issue report. There is a file libinterp/op-kw-docs which contains help text for keywords and operators. It probably needs the addition of "classdef", "properties", "enumeration", etc.

Rik <rik5>
Project Administrator
Mon 04 Dec 2017 10:45:43 PM UTC, comment #3:

This classdef needs some work. Just typing the file causes a crash:

The use of Crash.c1 immediately after its definition is what's causing the segfault. The following:

does not cause a crash, but it still doesn't handle typing correctly:

Note that there is no "help" for classdef:

Definitely some interpreter issues, and probably not a minor fix.

Dan Sebald <sebald>
Mon 04 Dec 2017 12:00:43 PM UTC, comment #2:

FWIW, in Matlab r2017b:

Octave 4.3.0+ (a tip from 26 nov) segfaults already at just a:

which Crash

Status -> confirmed
Release -> dev

Philip Nienhuis <philipnienhuis>
Project Member
Mon 04 Dec 2017 02:38:38 AM UTC, comment #1:

I can confirm that there is some strangeness. With 4.2.1, I get

That alone is weird. With the development branch I get a true segfault.

On the other hand, is this even valid code? Does it run under Matlab?

It appears to me that this line

will cause an infinite loop. The first time an object of the class is created the class will try to be initialized. The line 'c1 = 1' is straightforward. The next line will allocate space for the variable c2, but then will call the class constructor Crash because 'Crash.c1' does not yet exist as a class constant variable since the first initialization has not finished.

Rik <rik5>
Project Administrator
Sun 03 Dec 2017 04:47:55 PM UTC, original submission:

If an instance of the following class is created with
ans = Crash;
or if c2 is accessed with
ans = Crash.c2;
Octave will crash.

classdef Crash < handle
properties (Constant)
c1 = 1;
c2 = Crash.c1 + 1;

Damian Gisler <zweistein>


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

Attach Files:

Attached Files
file #42561:  Crash.m added by zweistein (110B - application/octet-stream)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by teerav42 (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by zweistein (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-11 mtmiller Dependencies- => bugs #45457 is dependent
    2019-03-03 rik5 Carbon-Copy- => Added jwe
    2018-12-21 mtmiller Item GroupOther => Incorrect Result
        Summary Dependent constant properties cause a crash => Dependent constant properties in classdef errors: no such file
    2017-12-05 rik5 Operating SystemMicrosoft Windows => Any
    2017-12-04 philipnienhuis StatusNone => Confirmed
        Release4.2.1 => dev
    2017-12-03 zweistein Attached File- => Added Crash.m, #42561

    Back to the top

    Powered by Savane 3.4