octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #50068] Segfault, when eval_string is used in


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #50068] Segfault, when eval_string is used in interpreter embedded mode
Date: Fri, 20 Jan 2017 22:17:25 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #14, bug #50068 (project octave):

We can fix the problem with the interpreter object being temporary in
octave_main by making it static.  But I'm not sure what to do about the new
way that clean_up_and_exit works.

If you want to update your code, you could write something like this instead:


#include <string>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/interpreter.h>

int
main (int argc, char** argv)
{
  string_vector octave_argv (2);
  octave_argv(0) = "embedded";
  octave_argv(1) = "-q";
  octave::embedded_application app (2, octave_argv.c_str_vec ());

  if (! app.execute ())
    {
      std::cerr << "creating embedded Octave interpreter failed!" <<
std::endl;
      exit (1);
    }

  try
    {
      int parse_status;

      eval_string (std::string ("x = 2;"), 0, parse_status);
      eval_string (std::string ("printf ('X = %d\\n', x);"), 0,
parse_status);
    }
  catch (const octave::exit_exception& ex)
    {
      exit (ex.exit_status ());
    }
  catch (const octave::execution_exception&)
    {
      std::cerr << "error evaluating Octave code!" << std::endl;
    }

  return 0;
}



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50068>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]