bugGNU Octave - Bugs: bug #57963, max_recursion_depth exceeded error...

 
 

bug #57963: max_recursion_depth exceeded error in non-recursive classdef static method

Submitter:  Richard <crobar>
Submitted:  Fri 06 Mar 2020 01:44:25 PM UTC
   
 
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Need Info Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  * Closed
Release:  * 5.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 09 Mar 2020 01:57:28 PM UTC, comment #3: 

Actually I'm struggling with this, a simple example I worked up, which should be the same, doesn't have the same problem. I might have to pare down the original code until it stops showing the error.

Richard <crobar>
Fri 06 Mar 2020 05:00:40 PM UTC, comment #2: 

Could you provide a complete example that demonstrates the problem?

John W. Eaton <jwe>
Group administrator
Fri 06 Mar 2020 03:27:59 PM UTC, comment #1: 

Actually never mind, the problem was this:


classdef structuralInternalForce < mbdyn.pre.force

    properties (GetAccess = public, SetAccess = protected)

        node1;
        node2;
        forceType;
        force;


I have a class with a property name the same as parent class (although not really as it's in a package, but there you go).

I think there's a bug about this somewhere, but note it's perfectly acceptable in Matlab, so if there isn't a bug report, there should be.

Workaround is to change the variable name.

Richard <crobar>
Fri 06 Mar 2020 01:44:25 PM UTC, original submission:  

I am getting the following error from some code:


error: max_recursion_depth exceeded
error: called from
    checkAllowedStringInputs at line 683 column 13
    set.defaultShape at line 148 column 13
    element at line 101 column 32
    force at line 23 column 18
    generateMBDynInputString at line 209 column 22
    generateMBDynInputString at line 254 column 21
    generateMBDynInputStr at line 1400 column 21
    generateMBDynInputFile at line 1430 column 17
    MBCNodal at line 348 column 25
    simStart at line 918 column 37
    run at line 613 column 31
    run_wecsim_in_octave at line 123 column 24
stopped in checkAllowedStringInputs at line 683 [/home/rcrozier/src/rnfoundry-hg/common/multibody/MBDyn/+mbdyn/+pre/base.m]
683:             assert (ischar (input), '%s must be a character vector', inputname);


This error is thrown in a classdef static method, which is not a recursive method, and doesn't call any recursive methods. The actual method itself is shown below:


        function [ ok, allowed_ind ] = checkAllowedStringInputs (input, allowedstrs, throw, inputname)
            % checks is string is one of a set of allowed values
            %
            % Syntax
            %
            %  ok = checkAllowedStringInputs (input, allowedstrs, throw)
            %  ok = checkAllowedStringInputs (..., inputname)
            %
            % Input
            %
            %  input - value to be tested if it is a valid string. The
            %   string will be compared to the list of valid strings in
            %   allowedstrs.
            %
            %  allowedstrs - cell string array of valid strings for
            %    comparison with input.
            %
            %  throw - logical flag determining whether an error is thrown
            %   by checkOrientationDescription if input fails check
            %
            %  inputname - (optional) string with name to use in error
            %    thrown by checkAllowedStringInputs (if 'throw' is true).
            %    The error will be "<name> must be one of: 'string 1' |
            %   'string 2' | 'string 3'" where allowedstrs is {'string 1',
            %   'string 2', 'string 3'}.
            %
            % Output
            %
            %  ok - logical flag indicating if check was passed
            %

            if nargin < 4
                inputname = 'input';
            end

            if ~iscellstr (allowedstrs)
                error ('allowedstrs must be a cell array of strings containing a list of allowed values for the input');
            end

            assert (ischar (input), '%s must be a character vector', inputname);

            ok = true;

            allowed_ind = find (strcmp (input, allowedstrs));

            if isempty(allowed_ind)
                ok = false;
            end

            if throw && ~ok

                error ('%s must be one of: %s ', inputname, sprintf (['''%s''', repmat(' | ''%s''', 1, numel(allowedstrs)-1)], allowedstrs{:}));

            end

        end



the line on which the error is thrown is:


assert (ischar (input), '%s must be a character vector', inputname);


Some interesting outputs when I run with debug on error and am stopped on the offending line:


debug> input
input = cuboid
debug> whos
Variables visible from the current scope:

variables in scope: checkAllowedStringInputs: /home/rcrozier/src/rnfoundry-hg/common/multibody/MBDyn/+mbdyn/+pre/base.m

   Attr Name             Size                     Bytes  Class
   ==== ====             ====                     =====  =====
    f   allowedstrs      1x9                         59  cell
        ans              1x1                          1  logical
    f   input            1x6                          6  char
    f   inputname        1x12                        12  char
    f   throw            1x1                          1  logical

Total is 29 elements using 79 bytes

debug> ischar ('cuboid')
ans = 1
debug> input
input = cuboid
debug>  max_recursion_depth
ans = 256.0000e+000
debug>
ans = 256.0000e+000
debug> inputname
inputname = DefaultShape
debug> ischar (input)
ans = 1
debug> assert (ischar (input), '%s must be a character vector', inputname);
error: max_recursion_depth exceeded
error: called from
    checkAllowedStringInputs at line 683 column 13
    set.defaultShape at line 148 column 13
    element at line 101 column 32
    force at line 23 column 18
    generateMBDynInputString at line 209 column 22
    generateMBDynInputString at line 254 column 21
    generateMBDynInputStr at line 1400 column 21
    generateMBDynInputFile at line 1430 column 17
    MBCNodal at line 348 column 25
    simStart at line 918 column 37
    run at line 613 column 31
    run_wecsim_in_octave at line 123 column 24
debug> assert (ischar ('cuboid'), '%s must be a character vector', inputname);
error: max_recursion_depth exceeded
error: called from
    checkAllowedStringInputs at line 683 column 13
    set.defaultShape at line 148 column 13
    element at line 101 column 32
    force at line 23 column 18
    generateMBDynInputString at line 209 column 22
    generateMBDynInputString at line 254 column 21
    generateMBDynInputStr at line 1400 column 21
    generateMBDynInputFile at line 1430 column 17
    MBCNodal at line 348 column 25
    simStart at line 918 column 37
    run at line 613 column 31
    run_wecsim_in_octave at line 123 column 24
debug> assert (true, 'something')
error: max_recursion_depth exceeded
error: called from
    checkAllowedStringInputs at line 683 column 13
    set.defaultShape at line 148 column 13
    element at line 101 column 32
    force at line 23 column 18
    generateMBDynInputString at line 209 column 22
    generateMBDynInputString at line 254 column 21
    generateMBDynInputStr at line 1400 column 21
    generateMBDynInputFile at line 1430 column 17
    MBCNodal at line 348 column 25
    simStart at line 918 column 37
    run at line 613 column 31
    run_wecsim_in_octave at line 123 column 24
debug> disp ('hello')
hello
debug> version
error: max_recursion_depth exceeded
error: called from
    checkAllowedStringInputs at line 683 column 13
    set.defaultShape at line 148 column 13
    element at line 101 column 32
    force at line 23 column 18
    generateMBDynInputString at line 209 column 22
    generateMBDynInputString at line 254 column 21
    generateMBDynInputStr at line 1400 column 21
    generateMBDynInputFile at line 1430 column 17
    MBCNodal at line 348 column 25
    simStart at line 918 column 37
    run at line 613 column 31
    run_wecsim_in_octave at line 123 column 24
debug>



so it seems any call to assert results in the error, but some function calls are ok (e.g. 'disp'), but calling the 'version' command results in the error. I only found this out because I wanted to put the octave version in this bug report.

I should also add that the code runs without error under Matlab.

Because this is a really wierd result, not replicable in Matlab and part of a pretty complex program, I'm not sure where to go from here in terms of getting this down to minimum example The method 'checkAllowedStringInputs' is called in many other places without error.

The same error occurs in Octave 5.2 release on windows, and also Octave built from hg id 5f57a71d67db tip @ on Mint Linux 19.3 (an ubuntu derivative).

The bulk of the code necessary to reproduce the error is open source (I am the author), but the specific example producing the error cannot be shared publicly.

Any idea where to go from here?

Richard <crobar>

 

(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 rik5 (Updated the item)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by crobar (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
    2024-01-30 rik5 Open/ClosedOpen Closed
    2024-01-23 mmuetzel CategoryInterpreter Classdef
    2020-03-06 jwe StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code