I have submitted a bug report whose text I reproduce below. A file with the code from below is attached to the bug report.
http://sourceforge.net/tracker/index.php?func=detail&aid=1164766&group_id=16572&atid=116572

Regards,
Rob.

Unhook() causes perl Warning
-------------------------------

This example shows a problem with Win32::GUI::UnHook()
method.

The UnHook call appears to be the cause of error messages:
Attempt to free unreferenced scalar: SV 0x1a5519c, Perl
interpreter: 0x15d40a4 at unhookBug.pl line 40.

From perldiag:
Attempt to free unreferenced scalar:
(W internal) Perl went to decrement the reference count of a
scalar to see if it would go to 0, and discovered that it had
already gone to 0 earlier, and should have been freed, and in
fact, probably was freed. This could indicate that
SvREFCNT_dec() was called too many times, or that
SvREFCNT_inc() was called too few times, or that the SV
was mortalized when it shouldn't have been, or that memory
has been corrupted.

Workaround:
It is possible to turn off internal warnings (that are on by
default) by setting no warnings (internal);

I'm certainly no XS expert, but it looks like it's possible to get
SvREFCNT_dec(*removedvalue) called twice in UnHook().
Is this the problem?

use strict;
use warnings; #Turning off internal warnings removes the messages
#no warnings qw(internal);

use Win32::GUI 1.0;
my $WM_MOUSEMOVE = 512;

my $mw = new Win32::GUI::Window (
   -size => [200,200],
);

$mw->Hook($WM_MOUSEMOVE, \&handler)
   or die "Failed to add Hook";

$mw->UnHook($WM_MOUSEMOVE, \&handler)
   or die "Failed to remove hook";

exit(0);

Reply via email to