bugGNU Octave - Bugs: bug #53925, local functions should be in...

 
 

bug #53925: local functions should be in auto-complete list for readline at command line

Submitter:  Rik <rik5>
Submitted:  Wed 16 May 2018 10:18:30 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 19 May 2018 12:09:56 AM UTC, comment #4: 

Works perfectly.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 18 May 2018 11:34:52 PM UTC, comment #3: 

I pushed the following changeset on stable and merged with default.  It seems to fix the problem for me.

http://hg.savannah.gnu.org/hgweb/octave/rev/9e39a53b4e00

The real problem was that the octave_user_function class didn't have an implementation of the virtual parent_fcn_scope, so the default implementation of that function was always returning an empty scope.

John W. Eaton <jwe>
Group administrator
Thu 17 May 2018 06:58:49 PM UTC, comment #2: 

I pushed a fix to the stable branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/644fe81ced33).

This stops the segfault, but the side effect is that local functions are not included in the auto-complete list for readline.  The problem is that curr_fcn->parent_fcn_scope() is returning a NULL pointer.  I don't know why that is, but the current fix is good enough for me.

I have re-titled the bug to reflect the minor open issue, and lowered the priority.

Rik <rik5>
Group administrator
Wed 16 May 2018 11:30:19 PM UTC, comment #1: 

I also see this problem on stable, so if possible it should be fixed there.

It's crashing here in the condition of the while loop in this function in help.cc:


  // Return a vector of all functions from this file,
  // for use in command line auto-completion.
  string_vector help_system::local_functions (void) const
  {
    string_vector retval;

    call_stack& cs = m_interpreter.get_call_stack ();

    octave_user_code *curr_fcn = cs.caller_user_code ();

    if (! curr_fcn)
      return retval;

    // All subfunctions are listed in the top-level function of this file.
    while (curr_fcn->is_subfunction ())
      {
        symbol_scope pscope = curr_fcn->parent_fcn_scope ();
        curr_fcn = pscope.function ();
      }

    // Get subfunctions.
    const std::list<std::string> names = curr_fcn->subfunction_names ();

    size_t sz = names.size ();
    retval.resize (sz);

    // Loop over them.
    size_t i = 0;
    for (const auto& nm : names)
      retval(i++) = nm;

    return retval;
  }


The value of curr_fcn is NULL.  You are stopped in a subfunction, so finding the ultimate parent function should be possible.

John W. Eaton <jwe>
Group administrator
Wed 16 May 2018 10:18:30 PM UTC, original submission:  

The following code on the development branch of Octave, launched with "run-octave -f", causes a segfault:


octave:1> dbstop residue 293
ans =  293
octave:2> test residue
stopped in /home/rik/wip/Projects_Mine/octave-dev/scripts/polynomial/residue.m at line 293
293:   if (numel (e))
debug> varfatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault


In the last line I typed "var<TAB>" to have readline complete the identifier name.

If I start Octave with the "--no-line-editing" option there is no segfault, but of course there is also no readline library active.

Rik <rik5>
Group administrator

 

(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 (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-19 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-05-18 jwe StatusConfirmed Ready For Test
    2018-05-17 rik5 Priority5 - Normal 3 - Low
        Item GroupSegfault, Bus Error, etc. Feature Request
        StatusNone Confirmed
        Summarysegfault in debug mode when using TAB-complete from readline local functions should be in auto-complete list for readline at command line

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code