bugGNU Octave - Bugs: bug #59422, SWIG failure against Octave 6.0

 
 

bug #59422: SWIG failure against Octave 6.0

Submitter:  Rafael Laboissière <rlaboiss>
Submitted:  Fri 06 Nov 2020 06:51:50 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Wont Fix 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

Thu 26 Nov 2020 01:39:28 AM UTC, comment #6: 

Thank you for the feedback 🙂

Closing report as won't fix.

Kai Torben Ohlhus <siko1056>
Group Member
Wed 25 Nov 2020 11:07:02 AM UTC, comment #5: 

I have already brought the issue to the attention of the SWIG upstream team: https://github.com/swig/swig/issues/1893#issuecomment-723500761

I agree with you there is very little to done at the Octave's side . You can close this bug report.

Rafael Laboissière <rlaboiss>
Tue 24 Nov 2020 04:32:09 AM UTC, comment #4: 

Is here something to be done for the Octave 6 release?

According to comment #2, Octave 6 seems not to be able to adapt to the current SWIG implementation.

Then this report can be handled downstream at the SWIG bug tracker and closed?

Kai Torben Ohlhus <siko1056>
Group Member
Sat 07 Nov 2020 10:28:44 PM UTC, comment #3: 

Thanks, John, for this detailed response.  I hope the SWIG developers will pay attention to it.

Rafael Laboissière <rlaboiss>
Fri 06 Nov 2020 03:05:15 PM UTC, comment #2: 

So, the short answer is that SWIG will at least have to change the definition of octave_swig_bound_func for Octave 6, even if we restore those other obsolete functions and variables and mark them as deprecated.

John W. Eaton <jwe>
Group administrator
Fri 06 Nov 2020 03:02:46 PM UTC, comment #1: 

The Octave parse tree evaluator was rewritten for version 6 and I could not see a way to provide an interface that is completely compatible with previous versions, so marking some functions as deprecated and simultaneously providing new and old interfaces to these internals did not seem to be an option.

To work with Octave 6, octave_swig_bound_func will have to provide an execute method.

You can ignore the error_state variable warnings as long as your code does not depend on it ever being non-zero.  Instead, Octave's error function will throw an octave::execution_exception exception.

It should be possible to replace oct_mach_info with octave::mach_info.  oct_mach_info and related functions were deprecated in version 4.4.  However, while there were some function names related to oct_mach_info that were deprecated it looks like maybe the oct_mach_info typedef itself was not?  Maybe we could restore that for another release or two?

Marking a symbol as global is now something that happens in a stack frame, not the symbol scope, which is just the collection of variables attached to a function, script, or the top-level workspace.  This confusion was a long-standing problem in Octave that I believe is now fixed.  Maybe we could provide a function in the symbol scope class that does the right thing, but  it will be deprecated and eventually removed.

Likewise for the functions that provide access to global variables.  Those are now something that belongs to the evaluator and there is access through the interpreter class.  But maybe we could provide some deprecated functions in the symbol table that would allow this SWIG code to continue to work.

I see no way to provide er
We might also be able to provide the call_stack::current function, but again, it would be deprecated and eventually removed so this code will have to change at some point.

It might also be possible to provide a discard_warning_messages global variable (maybe a reference?) that allows direct access to the error_system::m_discard_warning_messages internal variable, but again, it would be deprecated and removed in a couple of releases.

The global discard_error_messages varaible no longer exists in Octave as errors are printed when the exceptions they generate are caught, so setting a variable to tell the error function to discard messages is no longer needed.  But, similar to error_state, I suppose we could continue to provide the variable so code using it will compile, but the variable will do nothing.  I can't say whether that will allow SWIG code to work the same way as it did previously.

John W. Eaton <jwe>
Group administrator
Fri 06 Nov 2020 06:51:50 AM UTC, original submission:  

This is not a bug in Octave, per se. I just noticed that SWIG (a bindings generator) fails to generate wrappers for Octave 6.0.  I have already reported the bug to the upstream authors of SWIG.  I am also filing the present bug report and hope that the Octave developers may have insights on how to fix the problem.  Also, notice that the example below works with Octave 5.2.  The files shown below can also be found in the ZIP file attached to this bug report.

Let us say that we have the C file below, containing functions that we want to interface with Octave (example.c):


int fact(int n) {
  if (n <= 1) return 1;
  else return n*fact(n-1);
}

int my_mod(int x, int y) {
   return (x%y);
}


We then create the following interface file (example.i):


%module swig_test
%{
  extern int fact(int n);
  extern int my_mod(int x, int y);
%}

 extern int fact(int n);
 extern int my_mod(int x, int y);


The SWIG bindings would be obtained with these commands:


swig -octave -c++ example.i
mkoctfile example_wrap.cxx example.c > swig-mkoctfile.log 2>&1


However, the call to mkoctfile fails.  Here are the contents of the swig-mkoctfile.log file:


In file included from /usr/include/octave-6.0.90/octave/../octave/ov.h:63,
                 from /usr/include/octave-6.0.90/octave/../octave/ovl.h:38,
                 from /usr/include/octave-6.0.90/octave/../octave/ov-fcn.h:36,
                 from /usr/include/octave-6.0.90/octave/../octave/ov-builtin.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/defun-int.h:33,
                 from /usr/include/octave-6.0.90/octave/../octave/defun-dld.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/oct.h:35,
                 from example_wrap.cxx:175:
example_wrap.cxx: In static member function ‘static void octave_swig_bound_func::register_type(octave::type_info&)’:
/usr/include/octave-6.0.90/octave/../octave/ov-base.h:193:28: error: invalid new-expression of abstract class type ‘octave_swig_bound_func’
  193 |     octave_value v (new t ());                                  \
      |                            ^
example_wrap.cxx:1078:3: note: in expansion of macro ‘DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA’
 1078 |   DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_bound_func, "octave_swig_bound_func", "octave_swig_bound_func");
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx:1026:9: note:   because the following virtual functions are pure within ‘octave_swig_bound_func’:
 1026 |   class octave_swig_bound_func : public octave_function {
      |         ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/octave-6.0.90/octave/../octave/ov-builtin.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/defun-int.h:33,
                 from /usr/include/octave-6.0.90/octave/../octave/defun-dld.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/oct.h:35,
                 from example_wrap.cxx:175:
/usr/include/octave-6.0.90/octave/../octave/ov-fcn.h:247:3: note:     ‘virtual octave_value_list octave_function::execute(octave::tree_evaluator&, int, const octave_value_list&)’
  247 |   execute (octave::tree_evaluator& tw, int nargout = 0,
      |   ^~~~~~~
example_wrap.cxx: At global scope:
example_wrap.cxx:1753:10: error: ‘oct_mach_info’ has not been declared
 1753 |          oct_mach_info::float_format fmt) {
      |          ^~~~~~~~~~~~~
example_wrap.cxx:1753:38: error: expected ‘,’ or ‘...’ before ‘fmt’
 1753 |          oct_mach_info::float_format fmt) {
      |                                      ^~~
example_wrap.cxx: In member function ‘octave_value_list octave_swig_type::member_deref(octave_swig_type::member_value_pair*, const octave_value_list&)’:
example_wrap.cxx:1025:94: error: invalid new-expression of abstract class type ‘octave_swig_bound_func’
 1025 | #define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(new octave_swig_bound_func(func, args))
      |                                                                                              ^
example_wrap.cxx:1257:18: note: in expansion of macro ‘SWIG_OCTAVE_BOUND_FUNC’
 1257 |           return SWIG_OCTAVE_BOUND_FUNC(m->second.function_value(), args);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx:1025:94: error: invalid new-expression of abstract class type ‘octave_swig_bound_func’
 1025 | #define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(new octave_swig_bound_func(func, args))
      |                                                                                              ^
example_wrap.cxx:1265:18: note: in expansion of macro ‘SWIG_OCTAVE_BOUND_FUNC’
 1265 |           return SWIG_OCTAVE_BOUND_FUNC(new octave_builtin(m->first->method), args);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx: In member function ‘virtual dim_vector octave_swig_type::dims() const’:
example_wrap.cxx:1338:15: warning: ‘error_state’ is deprecated: [6]: this variable is obsolete and always has the value 0 [-Wdeprecated-declarations]
 1338 |           if (error_state) return dim_vector(1,1);
      |               ^~~~~~~~~~~
In file included from /usr/include/octave-6.0.90/octave/../octave/oct.h:36,
                 from example_wrap.cxx:175:
/usr/include/octave-6.0.90/octave/../octave/error.h:495:26: note: declared here
  495 | extern OCTINTERP_API int error_state;
      |                          ^~~~~~~~~~~
example_wrap.cxx:1348:16: warning: ‘error_state’ is deprecated: [6]: this variable is obsolete and always has the value 0 [-Wdeprecated-declarations]
 1348 |            if (error_state) return dim_vector(1,1);
      |                ^~~~~~~~~~~
In file included from /usr/include/octave-6.0.90/octave/../octave/oct.h:36,
                 from example_wrap.cxx:175:
/usr/include/octave-6.0.90/octave/../octave/error.h:495:26: note: declared here
  495 | extern OCTINTERP_API int error_state;
      |                          ^~~~~~~~~~~
example_wrap.cxx: At global scope:
example_wrap.cxx:2015:10: error: ‘oct_mach_info’ has not been declared
 2015 |          oct_mach_info::float_format fmt)
      |          ^~~~~~~~~~~~~
example_wrap.cxx:2015:38: error: expected ‘,’ or ‘...’ before ‘fmt’
 2015 |          oct_mach_info::float_format fmt)
      |                                      ^~~
example_wrap.cxx: In member function ‘virtual bool octave_swig_ref::load_binary(std::istream&, bool, int)’:
example_wrap.cxx:2016:43: error: ‘fmt’ was not declared in this scope; did you mean ‘fma’?
 2016 |       { return ptr->load_binary(is, swap, fmt); }
      |                                           ^~~
      |                                           fma
example_wrap.cxx: At global scope:
example_wrap.cxx:2125:10: error: ‘oct_mach_info’ has not been declared
 2125 |          oct_mach_info::float_format fmt) {
      |          ^~~~~~~~~~~~~
example_wrap.cxx:2125:38: error: expected ‘,’ or ‘...’ before ‘fmt’
 2125 |          oct_mach_info::float_format fmt) {
      |                                      ^~~
example_wrap.cxx: In function ‘octave_value SWIG_Octave_GetGlobalValue(std::string)’:
example_wrap.cxx:2377:35: warning: ‘octave_value octave::symbol_table::global_varval(const string&) const’ is deprecated: [6]: use 'interpreter::global_varval' instead [-Wdeprecated-declarations]
 2377 |   return symtab.global_varval(name);
      |                                   ^
In file included from /usr/include/octave-6.0.90/octave/../octave/interpreter.h:58,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-bp.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-cmd.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-decl.h:36,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-misc.h:32,
                 from /usr/include/octave-6.0.90/octave/../octave/parse.h:41,
                 from example_wrap.cxx:266:
/usr/include/octave-6.0.90/octave/../octave/symtab.h:199:18: note: declared here
  199 |     octave_value global_varval (const std::string& name) const;
      |                  ^~~~~~~~~~~~~
example_wrap.cxx: In function ‘void SWIG_Octave_SetGlobalValue(std::string, const octave_value&)’:
example_wrap.cxx:2386:35: warning: ‘void octave::symbol_table::global_assign(const string&, const octave_value&)’ is deprecated: [6]: use 'interpreter::global_assign' instead [-Wdeprecated-declarations]
 2386 |   symtab.global_assign(name, value);
      |                                   ^
In file included from /usr/include/octave-6.0.90/octave/../octave/interpreter.h:58,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-bp.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-cmd.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-decl.h:36,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-misc.h:32,
                 from /usr/include/octave-6.0.90/octave/../octave/parse.h:41,
                 from example_wrap.cxx:266:
/usr/include/octave-6.0.90/octave/../octave/symtab.h:238:10: note: declared here
  238 |     void global_assign (const std::string& name,
      |          ^~~~~~~~~~~~~
example_wrap.cxx: In function ‘void SWIG_Octave_LinkGlobalValue(std::string)’:
example_wrap.cxx:2396:12: error: ‘class octave::symbol_scope’ has no member named ‘assign’
 2396 |   symscope.assign(name, symtab.global_varval(name));
      |            ^~~~~~
example_wrap.cxx:2396:50: warning: ‘octave_value octave::symbol_table::global_varval(const string&) const’ is deprecated: [6]: use 'interpreter::global_varval' instead [-Wdeprecated-declarations]
 2396 |   symscope.assign(name, symtab.global_varval(name));
      |                                                  ^
In file included from /usr/include/octave-6.0.90/octave/../octave/interpreter.h:58,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-bp.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-cmd.h:35,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-decl.h:36,
                 from /usr/include/octave-6.0.90/octave/../octave/pt-misc.h:32,
                 from /usr/include/octave-6.0.90/octave/../octave/parse.h:41,
                 from example_wrap.cxx:266:
/usr/include/octave-6.0.90/octave/../octave/symtab.h:199:18: note: declared here
  199 |     octave_value global_varval (const std::string& name) const;
      |                  ^~~~~~~~~~~~~
example_wrap.cxx:2397:12: error: ‘class octave::symbol_scope’ has no member named ‘mark_global’
 2397 |   symscope.mark_global(name);
      |            ^~~~~~~~~~~
example_wrap.cxx: In function ‘bool SWIG_Octave_LoadModule(std::string)’:
example_wrap.cxx:2841:23: error: ‘discard_error_messages’ was not declared in this scope
 2841 |     frame.protect_var(discard_error_messages);          discard_error_messages = true;
      |                       ^~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx:2842:23: error: ‘discard_warning_messages’ was not declared in this scope
 2842 |     frame.protect_var(discard_warning_messages);        discard_warning_messages = true;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx: In function ‘bool SWIG_Octave_InstallFunction(octave_function*, std::string)’:
example_wrap.cxx:2884:23: error: ‘discard_error_messages’ was not declared in this scope
 2884 |     frame.protect_var(discard_error_messages);          discard_error_messages = true;
      |                       ^~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx:2885:23: error: ‘discard_warning_messages’ was not declared in this scope
 2885 |     frame.protect_var(discard_warning_messages);        discard_warning_messages = true;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
example_wrap.cxx: In function ‘octave_value_list Fswig_test(const octave_value_list&, int)’:
example_wrap.cxx:3125:73: error: ‘class octave::interpreter’ has no member named ‘get_call_stack’
 3125 |     octave::call_stack& stack = octave::interpreter::the_interpreter()->get_call_stack();
      |                                                                         ^~~~~~~~~~~~~~
example_wrap.cxx:3126:33: error: ‘class octave::call_stack’ has no member named ‘current’
 3126 |     octave_function *me = stack.current();
      |                                 ^~~~~~~


Rafael Laboissière <rlaboiss>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50214:  octave-swig-example.zip added by rlaboiss (3KiB - application/zip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rlaboiss (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
    2020-11-26 siko1056 Severity4 - Important 3 - Normal
        StatusNeed Info Wont Fix
        Open/ClosedOpen Closed
        Release6.0.90 dev
    2020-11-24 siko1056 Severity3 - Normal 4 - Important
        StatusNone Need Info
    2020-11-06 rlaboiss Attached File- Added octave-swig-example.zip, #50214

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code