Commit graph

3,984 commits

Author SHA1 Message Date
Thomas Maslach
de6b433cb1 Fix Python crash when using -threads iterating containers
Also fixes li_std_vector_enum testcase when run with -threads.

Patch supplied on swig-devel mailing list on 12 Sep with details...

==============================================
I just wanted to mention that I found a crash issue in bug..

I am using SWIG 2.0.11 with python and have –threads enabled.  I have a C++ std::vector that I instantiate in SWIG with %template.  I also have a method in a class that returns this vector.  I also include std_vector.i, btw..

When I iterate like so:

children = Action.getActionList()
for child in children:
  pass

Everything is fine..

When I iterate like this:

for child in Action.getActionList()
  pass

Product crashes.

The problem is the following.  This code gets called first:

SWIGINTERN PyObject *_wrap_delete_SwigPyIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = 0;
  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  PyObject * obj0 = 0 ;

  if(!PyArg_UnpackTuple(args,(char *)"delete_SwigPyIterator",1,1,&obj0)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SwigPyIterator" "', argument " "1"" of type '" "swig::SwigPyIterator *""'");
  }
  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
  {
    SWIG_PYTHON_THREAD_BEGIN_ALLOW;
    delete arg1;
    SWIG_PYTHON_THREAD_END_ALLOW;
  }
  resultobj = SWIG_Py_Void();
  return resultobj;
fail:
  return NULL;
}

Note the SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW. In between those two statements, we delete arg1.  That in turn will eventually end up in this code:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      Py_XDECREF(_obj);
    }

Uh-oh!  We call Py_XDECREF when we aren’t supposed to because we are in a SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW section!

This takes care of the issue:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
      Py_XDECREF(_obj);
      SWIG_PYTHON_THREAD_END_BLOCK;
    }

There are several other methods in this class that use the Python API, but don’t have the BEGIN/END block defined.  I’m not sure if they are required for all of them, but I believe they are..

I have attached a modified pyclasses.swg with what I believe are the correct changes.  This code is from 2.0.11, but as far as I can tell, it’s the same as what is in 3.0.2…

Apologies for not doing more here (making/running tests, getting it in the code repository, etc..), but I’m under some pressure to get some unrelated things done…
2014-09-23 22:33:25 +01:00
William S Fulton
783e816d89 Testcase warning suppression 2014-09-23 19:54:13 +01:00
William S Fulton
8128b1e12f For Android examples, replace hard coded tool names with those detected at configure time. 2014-09-15 19:44:18 +01:00
Simon Marchetto
ef687d801e scilab: fix C++ examples cleaning 2014-09-15 10:22:42 +02:00
Olly Betts
1a99212c2c [PHP] Add support for specifying any PHP interfaces a wrapped class
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
2014-09-12 12:48:37 -03:00
Simon Marchetto
d89f3bde90 scilab: fix Examples Makefile exit code 2014-09-12 12:04:40 +02:00
Olly Betts
e12322df86 [PHP] Fix throwing a PHP exception through C++ from a subclassed
director method - PHP NULL gets returned by the subclassed method
in this case, so the directorout typemap needs to allow that (at
least if an exception is active).
2014-09-11 13:09:08 -03:00
Olly Betts
fa94a29df4 Fix comment typo 2014-09-11 13:06:17 -03:00
Simon Marchetto
2bcd768909 scilab: display loading errors in examples 2014-09-11 08:56:04 +02:00
Ian Lance Taylor
acaaa0f31f [Go] Add goargout typemap. 2014-09-09 11:28:04 -07:00
Olly Betts
0dd7b61c57 Fix segmentation faults with directors in PHP >= 5.4 2014-09-09 13:39:30 -03:00
Simon Marchetto
e107faf5cc scilab: remove error messages in example contract 2014-09-09 14:47:20 +02:00
Simon Marchetto
7cd7166991 scilab: remove example matrix2 warnings 2014-09-09 14:21:06 +02:00
Ian Lance Taylor
be145043df Add run test case for argout.i. 2014-09-07 15:44:12 -07:00
Ian Lance Taylor
1addbb46a8 [Go] Add imtype, goin, goout, godirectorin, and godirectorout
typemaps, to support writing Go code to convert between types.
2014-09-05 17:54:19 -07:00
Olly Betts
6eaec9ce7c Update expected output for pp_constant error test 2014-09-04 09:29:20 -03:00
Olly Betts
b9fe7b5f00 Disable case in pp_constant.i which never actually worked 2014-09-03 17:18:11 -03:00
William S Fulton
ae6782ea34 Suppress testcase warning 2014-09-03 20:07:50 +01:00
William S Fulton
ea634d54a5 Synchronize common scilab examples with other languages 2014-09-03 07:18:10 +01:00
Olly Betts
d3b3ff2c78 Fix comment typo 2014-09-02 23:12:35 -03:00
William S Fulton
a41efbd0f7 File renames in Scilab std_list example
Conform to usual file naming used in SWIG examples.
2014-09-02 20:34:19 +01:00
William S Fulton
d3a54e50f8 Have just one Scilab constants example
Same example as other languages, but using %scilabconst(1)
2014-09-02 20:29:45 +01:00
William S Fulton
2831d891cd Use CXXSRCS for testing for Scilab like other languages 2014-09-02 20:12:19 +01:00
William S Fulton
7acf8de21e Scilab overloaded method testcase warning suppression 2014-09-01 19:56:39 +01:00
William S Fulton
b707ee0fc8 Suppress Identifier name exceeds 24 characters warning in Scilab example 2014-09-01 19:47:49 +01:00
William S Fulton
a022dc44cd Add RUNPIPE back in for Scilab examples 2014-09-01 19:46:56 +01:00
Alexey Pelykh
abb888cfdd Clean-up test suite and fix issue with nspace, as well as keep the fix for Class::Struct::EnumClass being JNI-referenced as Struct_EnumClass 2014-08-31 12:14:29 +03:00
Alexey Pelykh
d318f03efe C++11 strongly-typed enums fix for Java only (proper) 2014-08-30 11:58:52 +03:00
Alexey Pelykh
d1b1925270 Additional test cases for C++11 strongly-typed enums 2014-08-30 09:08:04 +03:00
Richard
a3946e1520 Remove unneeded parameter 2014-08-28 19:46:52 -05:00
Richard
b8d7cc21b9 Use macros for V8 items 2014-08-28 19:46:52 -05:00
Richard
c23375d39d Show V8 Deprecated warnings 2014-08-28 19:46:51 -05:00
Richard
2a662502a5 Fixed buffer overrun 2014-08-28 19:46:49 -05:00
Richard
b0afc7a9a5 Allow to specify V8 version, for example:
V8_VERSION=0x031511 ENGINE=v8 make check-javascript-test-suite
2014-08-28 19:46:49 -05:00
Richard
19d2976962 Allow to specify V8 version, for example
V8_VERSION=0x031511 ENGINE=v8 make check-javascript-examples
2014-08-28 19:46:49 -05:00
William S Fulton
332c02ae2d Scilab minor build system improvement 2014-08-26 19:52:03 +01:00
Vadim Zeitlin
15b369028f Allow using enum elements as default values for Python functions.
Enum values are just (integer) constants in Python and so can be used as the
function default values just as well as literal numbers, account for this when
checking whether function parameters can be represented in Python.

Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to
describe better what this function does.
2014-08-17 01:08:32 +02:00
Robert Stone
488aed4224 apply SF Patch #350 and add testcase 2014-08-15 21:47:10 -07:00
Johan Hake
1dd297ad9d Fix issue with relative import when using single header file import.
-- The commit propagates the package option to the newly create
     module node so it is recognized by SWIG
  -- Added a relativeimport test for this combination
     (in lack of py3 I was not able to test it with py3 but it
      "should just work")
2014-08-12 21:48:26 +02:00
Simon Marchetto
31022667d6 scilab: file name is 'example' as in other examples 2014-08-08 17:47:36 +02:00
Simon Marchetto
9b427cc2e0 scilab: add missing exit in template example 2014-08-08 11:57:34 +02:00
Simon Marchetto
98d823face scilab: template example same as in other languages 2014-07-24 17:25:58 +02:00
Simon Marchetto
f602d6209e scilab: fix comment typo 2014-07-24 17:14:42 +02:00
Simon Marchetto
7c9a7ea78a scilab: remove indentation in example 2014-07-24 17:14:24 +02:00
Simon Marchetto
20987c42d0 scilab; new example scilab_const 2014-07-24 17:13:33 +02:00
Simon Marchetto
e37319b9be scilab: enum example same as in other languages 2014-07-24 17:09:19 +02:00
Simon Marchetto
d8a0594254 scilab: constants example same as in other languages 2014-07-24 16:34:54 +02:00
Simon Marchetto
bb4b6742eb scilab: hide too long identifier warnings 2014-07-24 11:14:07 +02:00
Yuval Kashtan
093fe2a556 Add support for java.nio.Buffer
including test-suite test case and documentation
2014-07-18 15:45:16 +03:00
Simon Marchetto
7ce1550664 scilab: fix missing include in li_std_container_typemaps test 2014-07-10 12:54:57 +02:00