Re: Segfault from GTK2.Notebook switch_page signal

Chris Angelico <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <CAPTjJmrcU74JuUc1=xEVNzty2vBcFpMsoUUg-EKcqptaZeG4nQ@mail.gmail.com>
On Fri, Jan 31, 2014 at 10:22 AM, Chris Angelico <[email protected]> wrote:
> Obviously, for compatibility with other GTK bindings and with previous
> versions of Pike, some sort of parameter should be given. But since it
> appears to be quite useless, I don't think it'd hurt to simply return
> the integer value of the pointer. However, I don't see any way to
> override it for just one signal. Is it worth it? Or should it just be
> documented as "don't touch this"?

Picking this up again. (It feels like ages ago that I was looking into
this, but it was only a month or so according to the datestamp.)

I can't find many cases where a signal argument uses G_TYPE_POINTER,
but every one I've tested has had the same segfault. So in the
interests of simplicity, I'm looking at turning all such pointers into
integers (see attached patch). Does anyone know of an actual use-case
that needs the Pike object pointer?

ChrisA
0001-Represent-G_TYPE_POINTER-as-an-integer-to-prevent-se.patch (text/x-patch, 854 B)
From 00e7a6ec001d5e163b8418ddc1eb3b0af66fbb8c Mon Sep 17 00:00:00 2001
From: Chris Angelico <[email protected]>
Date: Sat, 15 Mar 2014 11:11:05 +1100
Subject: [PATCH] Represent G_TYPE_POINTER as an integer to prevent segfaults

---
 src/post_modules/GTK2/source/support.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/post_modules/GTK2/source/support.c b/src/post_modules/GTK2/source/support.c
index 956fa7c..5aa8967 100644
--- a/src/post_modules/GTK2/source/support.c
+++ b/src/post_modules/GTK2/source/support.c
@@ -599,9 +599,7 @@ static int pgtk2_push_object_param(const GValue *a) {
 }
 
 static int pgtk2_push_pike_object_param(const GValue *a) {
-  struct object *o=g_value_get_pointer(a);
-  if (o)
-    ref_push_object(o);
+  push_int64((LONGEST)g_value_get_pointer(a));
   return PUSHED_VALUE;
 }
 
-- 
1.7.10.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.