bugGNU Octave - Bugs: bug #52567, invoking octave with conflicting...

 
 

bug #52567: invoking octave with conflicting arguments dumps core

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Fri 01 Dec 2017 01:28:22 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
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
   

Jump to the original submission

Fri 01 Dec 2017 07:25:57 PM UTC, comment #6: 

I pushed the final changeset, which changes all calls to warning() in octave.cc with direct printing of the message to std::cerr, here: http://hg.savannah.gnu.org/hgweb/octave/rev/cac0f8a1c696.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 01 Dec 2017 06:42:30 AM UTC, comment #5: 

OK, I found the function in the code (error.cc).

Those remaining two uses of warning will surely fail if the two others fail.  They are called immediately at the start of main.

Out of curiosity, I looked at the warning() routine.  It's pretty standard code, using variable argument list routines, up until calling this routine:


static void
warning_1 (const char *id, const char *fmt, va_list args)
{
  int warn_opt = warning_enabled (id);

  if (warn_opt == 2)
    {
      // Handle this warning as an error.

      error_1 (std::cerr, "error", id, fmt, args);
    }
  else if (warn_opt == 1)
    {
      bool fmt_suppresses_backtrace = false;
      size_t fmt_len = (fmt ? strlen (fmt) : 0);
      fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n');

      if (fmt_suppresses_backtrace && fmt_len > 1)
        {
          // Strip newline before issuing warning
          std::string tmp_fmt (fmt, fmt_len - 1);
          vwarning ("warning", id, tmp_fmt.c_str (), args);
        }
      else
        vwarning ("warning", id, fmt, args);

      octave::call_stack& cs = octave::__get_call_stack__ ("warning_1");

      bool in_user_code = cs.caller_user_code () != nullptr;

      if (! fmt_suppresses_backtrace && in_user_code
          && Vbacktrace_on_warning
          && ! discard_warning_messages)
        pr_where (std::cerr, "warning");

      if ((octave::application::interactive ()
           || octave::application::forced_interactive ())
          && Vdebug_on_warning && in_user_code && bp_table::debug_on_warn (id))
        {
          octave::unwind_protect frame;
          frame.protect_var (Vdebug_on_warning);
          Vdebug_on_warning = false;

          octave::tree_evaluator::debug_mode = true;

          octave::tree_evaluator::current_frame = cs.current_frame ();

          do_keyboard (octave_value_list ());
        }
    }
}


From about


       octave::call_stack& cs = octave::__get_call_stack__ ("warning_1");


onward the code becomes dodgy as to whether stack, protect, current frame and do_keyboard are using things all properly initialized by this point.

Dan Sebald <sebald>
Fri 01 Dec 2017 05:52:15 AM UTC, comment #4: 

I'm pretty sure warning() is referencing the Octave interpreter function, which is a problem at this stage since the interpreter, exception handling routines, etc. are not installed yet.

We should probably print an additional prefix like "error:".  I've attached a second cset that does that.

There are two remaining instances of warning in octave.cc.  They seem to be associated with creating an embedded interpreter.  They should also be tested to see if there is a problem.  There is an example in Appendix A, and some sample code in examples/code that could probably be used to create a test bed.

(file #42542)

Rik <rik5>
Group administrator
Fri 01 Dec 2017 05:32:48 AM UTC, comment #3: 

Works here.  Do you want some type of warning/error prompt before the message?  E.g.:


error: --eval "CODE" and script file are mutually exclusive options
usage: octave [-HVWdfhiqvx] [--debug] [--debug-jit] [--doc-cache-file file]
       [--echo-commands] [--eval CODE] [--exec-path path]
       [--force-gui] [--help] [--image-path path]
       [--info-file file] [--info-program prog] [--interactive]
       [--jit-compiler] [--line-editing] [--no-gui] [--no-history]
       [--no-init-file] [--no-init-path] [--no-line-editing]
       [--no-site-file] [--no-window-system] [--norc] [-p path]
       [--path path] [--persist] [--silent] [--traditional]
       [--verbose] [--version] [file]


What is "warning()" function?  A gnulib command?  Or is it somehow accessing the equivalent of Octave interpreter function "warning"?  If the latter, is the use of "warning()" in the early stages of launch a problem?

Dan Sebald <sebald>
Fri 01 Dec 2017 05:14:42 AM UTC, comment #2: 

The interpreter should never segfault, even for erroneous input.

I have some guesses as to why this is happening, but the simplest thing to do is probably to print the message directly to stderr rather than going through warning().

And looking through octave.cc, this is not the only place where warning() is used.  I tried combining --eval CODE with specifying an m-file to run and got a slightly different core dump.
)


./run-octave -f --eval 'disp (pi);' tst_plotyy.m
warning: --eval "CODE" and script file are mutually exclusive options
octave exited with signal 6


Try the attached patch 52567.cset.  It works for me.


(file #42541)

Rik <rik5>
Group administrator
Fri 01 Dec 2017 02:23:15 AM UTC, comment #1: 

Confirmed.  If I comment out the warning() call:


diff --git a/libinterp/octave.cc b/libinterp/octave.cc
--- a/libinterp/octave.cc
+++ b/libinterp/octave.cc
@@ -232,7 +232,7 @@ namespace octave
     // Check for various incompatible argument pairs
     if (m_force_gui && m_no_gui)
       {
-        warning ("only one of --force-gui and --no-gui may be used");
+//        warning ("only one of --force-gui and --no-gui may be used");

         octave_print_terse_usage_and_exit ();
       }


I see the usage message and no abort signal:


sebald@ ~/octave/bug_52550 $ /usr/local/src/octave/octave/build1/run-octave --no-gui --f

usage: octave [-HVWdfhiqvx] [--debug] [--debug-jit] [--doc-cache-file file]
       [--echo-commands] [--eval CODE] [--exec-path path]
       [--force-gui] [--help] [--image-path path]
       [--info-file file] [--info-program prog] [--interactive]
       [--jit-compiler] [--line-editing] [--no-gui] [--no-history]
       [--no-init-file] [--no-init-path] [--no-line-editing]
       [--no-site-file] [--no-window-system] [--norc] [-p path]
       [--path path] [--persist] [--silent] [--traditional]
       [--verbose] [--version] [file]


Dan Sebald <sebald>
Fri 01 Dec 2017 01:28:22 AM UTC, original submission:  

./run-octave --no-gui --force-gui
warning: only one of --force-gui and --no-gui may be used
Aborted (core dumped)

(this was a result of a typo "./run-octave --f --no-gui")

Probably a low priority...

Dmitri.

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #42542:  52567.v2.cset added by rik5 (1KiB - application/octet-stream)
file #42541:  52567.cset added by rik5 (1KiB - application/octet-stream)

 

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 sebald (Posted a comment)
  • -email is unavailable- added by dasergatskov (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-12-01 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2017-12-01 rik5 Attached File- Added 52567.v2.cset, #42542
    2017-12-01 rik5 Attached File- Added 52567.cset, #42541
        CategoryNone Interpreter
        StatusNone Patch Submitted

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code