You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2017/02/25 16:35:58 UTC

[1/2] lucy-clownfish git commit: Fix global destruction check

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 4aea9977c -> 45be7f49b


Fix global destruction check

PL_dirty is already set during the first phase of global destruction
when it's still safe and even expected to destroy objects. Change the
test to check the refcount.

This fixes destruction of "our" variables like in Lucy's
t/308-simple.t.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/cd847f24
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/cd847f24
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/cd847f24

Branch: refs/heads/master
Commit: cd847f2425f2410c16606d19738d19dac1f5f3db
Parents: 4aea997
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Feb 23 23:18:33 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 25 17:24:55 2017 +0100

----------------------------------------------------------------------
 .../perl/buildlib/Clownfish/Build/Binding.pm    | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cd847f24/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 4a00766..dd976b5 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -747,17 +747,21 @@ END_POD
 MODULE = Clownfish     PACKAGE = Clownfish::Obj
 
 void
-DESTROY(self)
-    cfish_Obj *self
+DESTROY(sv)
+    SV *sv
 PPCODE:
-    /*
-     * During global destruction, DESTROY is called in random order on
-     * objects remaining because of refcount leaks or circular references.
-     * This can cause memory corruption with Clownfish objects, so better
-     * leak instead of corrupting memory.
-     */
-    if (!PL_dirty) {
-        CFISH_Obj_Destroy(self);
+    if (sv_derived_from(sv, "Clownfish::Obj")) {
+        /*
+         * During global destruction, DESTROY is called in random order on
+         * objects remaining because of refcount leaks or circular references.
+         * This can cause memory corruption with Clownfish objects, so better
+         * leak instead of corrupting memory.
+         */
+        SV *inner = SvRV(sv);
+        if (SvREFCNT(inner) <= 1) {
+            cfish_Obj *self = INT2PTR(cfish_Obj*, SvIV(inner));
+            CFISH_Obj_Destroy(self);
+        }
     }
 
 SV*


[2/2] lucy-clownfish git commit: Add explanation regarding SUPER::method invocations

Posted by nw...@apache.org.
Add explanation regarding SUPER::method invocations

This will hopefully remind me why we have to use static dispatch in
XSUBs.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/45be7f49
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/45be7f49
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/45be7f49

Branch: refs/heads/master
Commit: 45be7f49b06826a8b46b796c8745b2ec941ca154
Parents: cd847f2
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Feb 25 17:22:57 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 25 17:35:18 2017 +0100

----------------------------------------------------------------------
 compiler/src/CFCPerlClass.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/45be7f49/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index 30e9043..fe40119 100644
--- a/compiler/src/CFCPerlClass.c
+++ b/compiler/src/CFCPerlClass.c
@@ -269,7 +269,9 @@ CFCPerlClass_method_bindings(CFCClass *klass) {
          * directly calls the implementing function, rather than invokes the
          * method on the object using vtable method dispatch.  Doing things
          * this way allows SUPER:: invocations from Perl-space to work
-         * properly.
+         * properly. (The callback to the Perl method is stored in the
+         * vtable as well. Using dynamic dispatch for SUPER:: invocations
+         * would result in calling the Perl method over and over.)
          */
         CFCPerlMethod *meth_binding = CFCPerlMethod_new(klass, method);
         size_t size = (num_bound + 2) * sizeof(CFCPerlMethod*);