Glib 1.261 and ref counting with perl 5.14 (was: Re: Issue with Glib 1.260 in Windows 7)



On 7/5/2012 at  6:54 PM, "Martin Schlemmer" <Martin Schlemmer nwu ac za>
wrote:
On 2012/07/01 at 09:49 PM, "Martin Schlemmer" <Martin Schlemmer nwu ac za>
wrote:
On 2012/06/29 at 11:28 PM, Torsten Schoenfeld <kaffeetisch gmx de>
wrote:
On 15.06.2012 17:13, Martin Schlemmer wrote:
----------------------------
     $view = Gtk2::WebKit::WebView->new;
     $session = Gtk2::WebKit->get_default_session;
----------------------------

If you still have this set up, a couple of questions:

* Does non-crashing Glib 1.240 test case run against the same
libsoup 
that the crashing Glib 1.260 test case runs against?


Yep.

* How often does gdb reach the breakpoint 
"soup-session-async.c:finalize" when you run with Glib 1.260?  (Here
on 
Linux, it's just once.)



This is with Gtk3::WebKit and HTTP:Soup (so assume mostly G-O-I perl objects):

Over here it only reaches it only once as well, but the SV is not valid 
(another crash when I try to dump it), so I assume the SV was already freed, 
but not the qdata for the SoupSession GObject?

Side note, Glib-1.240 crash outside GDB, while inside it runs fine, Glib-1.260 
trigger a segfault inside GDB as well.


Firstly, this works fine with AS Perl 5.16.0.

Trying to track this down (AS Perl 5.14.2 MSWin32-x86), I looked at:

http://git.gnome.org/browse/perl-Glib/commit/?id=1361e9d22763ef008b6f3bcd82ffeb53c80120c5

and modified Glib-1.261's gobject_destroy_wrapper() to add back:

-----
-    if (PL_in_clean_objs)
-        return;
-----

Now it (see attached example) started to work like 1.240 where it would be fine running from GDB, but 
segfaults outside, so I rebuilt it with -DNOISY and got the backtrace below (let me know if I should send 
logs from -DNOISY as well).

Long story short, it seems that with older perl versions and things like WebKit and its SoupSession where the 
GObject outlives the HV:
- either the HV is already dead when the GObject calls gobject_destroy_wrapper(), and it segfaults in 
_gperl_remove_mg() (with PL_in_clean_objs == TRUE)
- or in the non GDB case, global destruction has already run, and it segfaults when touching any perl 
internals

I am not sure of how big a factor threads are (GDB vs non-GDB case), but this is the only example I currently 
have which exposes this problem.

Attached is a patch that fixes both these cases for me, but I am not sure if it is the correct fix. Only one 
test fails, but it also fails without (see below).

Let me know if any more information is needed, or if I can help in any other way.


Thanks,
Martin

-----
t/a.t ...................... 1/30
#   Failed test 'default log handler: install undef, prev default'
#   at t/a.t line 78.
#          got: undef
#     expected: 'CODE(0x252874c)'
# Looks like you failed 1 test of 30.
t/a.t ...................... Dubious, test returned 1 (wstat 256, 0x100)
-----

-----
Program received signal SIGSEGV, Segmentation fault.
0x2808439c in perl514!Perl_newSVpvn_flags () from c:\perl\bin\perl514.dll
(gdb) bt
#0  0x2808439c in perl514!Perl_newSVpvn_flags () from c:\perl\bin\perl514.dll
#1  0x280a3ccb in perl514!Perl_vform () from c:\perl\bin\perl514.dll
#2  0x280a4468 in perl514!Perl_vwarn () from c:\perl\bin\perl514.dll
#3  0x280a44a6 in perl514!Perl_warn_nocontext () from c:\perl\bin\perl514.dll
#4  0x6fb8dada in gobject_destroy_wrapper (obj=0x260256d) at GObject.xs:794
#5  0x685d1be6 in g_datalist_clear (datalist=0x48e0028) at gdataset.c:283
#6  0x63a4836b in g_object_unref (_object=0x48e0020) at gobject.c:3018
#7  0x66b985f0 in webkitExit() () from C:\opt\mingw-gtk2\bin\libwebkitgtk-1.0-0.dll
#8  0x048e0020 in ?? ()
#9  0x66b8109c in DllMainCRTStartup 12 (hDll=0x66b80000, dwReason=0, lpReserved=0x1) at ../mingw/dllcrt1.c:124
#10 0x77019950 in ntdll!RtlpNtMakeTemporaryKey () from C:\Windows\system32\ntdll.dll
#11 0x66b80000 in ?? ()
#12 0x7702d6b2 in ntdll!LdrVerifyImageMatchesChecksum () from C:\Windows\system32\ntdll.dll
#13 0x66b81058 in __dll_exit () at ../mingw/dllcrt1.c:158
#14 0x7702d554 in ntdll!TpSetPoolStackInformation () from C:\Windows\system32\ntdll.dll
#15 0x006327d8 in ?? ()
#16 0x74a279f5 in KERNEL32!BasepFreeActivationContextActivationBlock () from C:\Windows\syswow64\kernel32.dll
#17 0x00000000 in ?? ()
(gdb)



Vrywaringsklousule / Disclaimer:  http://www.nwu.ac.za/it/gov-man/disclaimer.html 

Attachment: Glib-fix-older-ref-counting.patch
Description: Text document

Attachment: ref-count-test.pl
Description: Binary data



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