[perl-Glib-Object-Introspection] Fix a stack handling bug for Perl vfuncs



commit 0095be2381c4ad888e6ef61098710dee2f411d3c
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Wed Jun 25 22:44:52 2014 +0200

    Fix a stack handling bug for Perl vfuncs
    
    When there is a Perl implementation for a vfunc, invoking a C function that
    invokes this vfunc might end up reallocating the Perl stack and hence
    invalidating the local 'sp' pointer.  Fix with a pair of PUTBACK/SPAGAIN.
    
    Triggered by Gtk3's test suite.

 NEWS                  |    1 +
 gperl-i11n-invoke-c.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 9d7f707..95b0f1f 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Overview of changes in Glib::Object::Introspection 0.023
 ========================================================
 
 * Fix return value handling on big-endian architectures.
+* Fix a stack handling bug for Perl vfuncs.
 
 Overview of changes in Glib::Object::Introspection 0.022
 ========================================================
diff --git a/gperl-i11n-invoke-c.c b/gperl-i11n-invoke-c.c
index 1b00543..1497836 100644
--- a/gperl-i11n-invoke-c.c
+++ b/gperl-i11n-invoke-c.c
@@ -198,7 +198,12 @@ invoke_c_code (GICallableInfo *info,
        return_value_p = &return_value;
 #endif
 
+       /* Wrap the call in PUTBACK/SPAGAIN because the C function might end up
+        * calling Perl code (via a vfunc), which might reallocate the stack
+        * and hence invalidate 'sp'. */
+       PUTBACK;
        ffi_call (&cif, func_pointer, return_value_p, iinfo.args);
+       SPAGAIN;
 
        /* free call-scoped data */
        _invoke_free_after_call_handlers (&iinfo);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]