Skip Menu |
 

This queue is for tickets about the Perl-Dist-Strawberry CPAN distribution.

Report information
The Basics
Id: 120043
Status: open
Priority: 0/
Queue: Perl-Dist-Strawberry

People
Owner: Nobody in particular
Requestors: simon.reinhardt [...] stud.uni-regensburg.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Term::ReadKey deadlocks with 5.24.1.1 release
Date: Mon, 30 Jan 2017 21:15:32 +0100
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: Simon Reinhardt <simon.reinhardt [...] stud.uni-regensburg.de>
Download (untitled) / with headers
text/plain 117b
See https://github.com/jonathanstowe/TermReadKey/issues/25 With the Term::ReadKey included in 5.20.1.1, it worked.
Download signature.asc
application/pgp-signature 819b

Message body not shown because it is not plain text.

On a MSWin32 ReadKey function looks like this:

sub ReadKey {
    my $File = normalizehandle((@_>1?$_[1]:\*STDIN));
    if ($_[0] || $CurrentMode >= 3) {
        Win32PeekChar($File, $_[0]);
    } else {
        getc $File;
    }
}

where Win32PeekChar looks like this:

SV * Win32PeekChar(file, delay)
        InputStream     file
        U32     delay <<<<<<<<<<<<<<<<< the trouble!!!
        CODE:
        {
                char key;
                if (Win32PeekChar(aTHX_ file, delay, &key))
                        RETVAL = newSVpv(&key, 1);
                else
                        RETVAL = newSVsv(&PL_sv_undef);
        }
        OUTPUT:
        RETVAL

So calling something like this:

my $x = ReadKey(1e-5);

means that the delay value 1e-5 is converted to U32 (unsigned 32bit integer) which I guess would be 0 (zero), therefore the same as calling my $x = ReadKey(0) - which is exactly what it does (blocking read waiting till you hit any key).

As for the versions:
- Strawberry Perl 5.20.1.1 has TermReadKey-2.31
- Strawberry Perl 5.24.1.1 has TermReadKey-2.37

And if you compare 2.31 vs. 2.37 you will find:

-int Win32PeekChar(PerlIO *file,double delay,char *key)
+int Win32PeekChar(pTHX_ PerlIO *file,U32 delay,char *key)

Note "double delay" vs. "U32 delay"

Full diff:
https://metacpan.org/diff/file?target=JSTOWE%2FTermReadKey-2.37%2F&amp;source=JSTOWE%2FTermReadKey-2.31

So IMHO definitely not a bug Strawberry Perl. ReadKey's Win32PeekChar needs a fix.

 


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.