[rt.cpan.org #53914] Bug report for Win32::API::Callback

[email protected] ("perlsite via RT")
Newsgroups perl.libwin32
Message-ID <[email protected]>
Fri Jan 22 06:26:39 2010: Request 53914 was acted upon.
Transaction: Ticket created by [email protected]
       Queue: Win32-API
     Subject: Bug report for Win32::API::Callback
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: [email protected]
      Status: new
 Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=53914 >


Hello,

The code below generate exception and application dies with the  
following "Error signature"

AppName: perl.exe     AppVer: 5.10.0.1004     ModName: perl510.dll
ModVer: 5.10.0.1004     Offset: 000961d5

# --- code start ---

#!/usr/bin/perl
use strict;
use Win32::API;
use Win32::API::Callback;

Win32::API->Import('kernel32', 'SetConsoleCtrlHandler', 'KL', 'L');
Win32::API->Import('kernel32', 'GenerateConsoleCtrlEvent', 'LL', 'L');
Win32::API->Import('kernel32', 'GetLastError', '', 'L');

sub cb {
     my ($dwCtrlType) = @_;

     open (FILE, '>c:/QUIT.TXT');
     print FILE "RECEIVED SIGNAL: $dwCtrlType\n";
     close FILE;

     return 0;
}

my $callback = Win32::API::Callback->new(\&cb, "L", "L");

SetConsoleCtrlHandler($callback, 1)  or die "Error: " . GetLastError() . "\n";

sleep(1);
GenerateConsoleCtrlEvent(0, 0);
sleep(2);

# --- code end ---

The error occurs when cb() routine is called, no matter whether it is  
triggered through GenerateConsoleCtrlEvent call or via while(1){} and  
Ctrl+C. Also specific implementation of cb() routine doesn't matter,  
i.e. callback body can be just return 0 or return 1 - same effect (in  
my implementation no file is created, so I assume that exception is  
generated when OS try to call the callback). My personal opinion is  
that $callback handler is not properly implemented.

My test fails both with Win32-API version 0.55 and 0.58 (ActiveState build).
I'm using Windows XP Professional, SP3 (up-to-date installation).

Regards,
Julian


-------------------------------------

Хостинг от 3.60 лв/м| Домейни от 17.46 лв/с ДДС| Сървъри, VPS от 48.00  
лв/м с ДДС!
18 GB място, Неограничен трафик, Безплатен домейн – 6.90 лв./м с ДДС!
25 GB място, 1200 GB трафик, Безплатен домейн – 11.46 лв./м с ДДС!
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.