#173 [RUBY] Swig patches

closed
None
9
2007-04-29
2007-04-18
No

After wrapping my first complex library, I've found three issues with the
swig ruby wrappings.

One of them is a serious one in rubyrun.swg that will result in segfaults/crash due to object tracking and the tracking not being removed for ruby objects that go out of scope.
This was often seen with static class variables (of things being tracked)
in classes, like:

class A {}
class B { static A myA; };

which would lead myA to be tracked incorrectly, eventually leading the
object tracked (as a number) to be retrieved, but by then the GC would have
already removed it, eventuall leading to __swigtype__ not being
found in the following lines. This issue was pretty hard to track, so let
me know if you need more clarification.

The two other patches are less serious. The one in rubytracking.swg just
uses a different macro than NUM2LONG to do the tracking, to deal
with platforms where there's a difference in datatype size (this is mostly
borrowed from latest ruby).

The third patch is the incorrect use of the STR2CSTR macro even on latest
versions of ruby. This was due to an improper #ifdef in a fragment in
rubystrings.swg.

The final patch is in making the ruby hashes visible instead of static. This is needed to have tracking work properly across a library split among several dsos.

Discussion

  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    File Added: rubystrings.swg.patch

     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    File Added: rubytracking.swg.patch

     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    File Added: ruby.cxx.patch

     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    File Added: rubyrun.swg.patch

     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    File Added: rubystrings.swg.patch

     
  • Gonzalo Garramuno

    • priority: 5 --> 9
    • assigned_to: nobody --> lyle
     
  • Gonzalo Garramuno

    Logged In: YES
    user_id=961712
    Originator: YES

    Finally, the last patch includes fixes to support SWIGing ruby modules under an embedded Ruby, when ruby_init() cannot be invoked in main().
    To do this appropriately, it is necessary to reset the ruby stack pointer on each swig director invocation or the ruby GC may end up collecting up memory belonging to the host application.
    As such, a new counter is added and two new macros may be defined (SWIG_INIT_STACK/SWIG_RELEASE_STACK).

    File Added: rubytracking.swg.patch

     
  • William Fulton

    William Fulton - 2007-04-28
    • assigned_to: lyle --> gga73
     
  • Gonzalo Garramuno

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks