Do not abort when unlinking non-data ruby objects
Fixes issue #1168.
Remove a call to abort() (introduced by commit
0e725b5d9b) made when SWIG_RubyUnlinkObjects()
is called on non T_DATA objects. It can happen when the destruction of T_DATA
objects is deferred: the Ruby GC first turn them to T_ZOMBIE, then calls their
free method (SWIG_RubyUnlinkObjects()).
This commit is contained in:
parent
717b7866d4
commit
a4884e45e1
2 changed files with 12 additions and 7 deletions
|
|
@ -39,7 +39,11 @@ GC.start
|
|||
# C++ object
|
||||
ok = false
|
||||
begin
|
||||
puts tiger2.get_name
|
||||
# Let's stress the GC a bit, a single pass might not be enough.
|
||||
10.times {
|
||||
GC.start
|
||||
puts tiger2.get_name
|
||||
}
|
||||
rescue ObjectPreviouslyDeleted => error
|
||||
ok = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -101,13 +101,14 @@ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
|
|||
|
||||
/* This is a helper method that unlinks a Ruby object from its
|
||||
underlying C++ object. This is needed if the lifetime of the
|
||||
Ruby object is longer than the C++ object */
|
||||
Ruby object is longer than the C++ object. */
|
||||
SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
|
||||
VALUE object = SWIG_RubyInstanceFor(ptr);
|
||||
|
||||
if (object != Qnil) {
|
||||
if (TYPE(object) != T_DATA)
|
||||
abort();
|
||||
// object might have the T_ZOMBIE type, but that's just
|
||||
// because the GC has flagged it as such for a deferred
|
||||
// destruction. Until then, it's still a T_DATA object.
|
||||
DATA_PTR(object) = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue