# New Ticket Created by  Sam S. 
# Please include the string:  [perl #128862]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128862 >


Golfed program to demonstrate the problem:

    my $server = IO::Socket::Async.listen('localhost', 3333);
    $server.tap: -> $conn {
        $conn.Supply.tap: -> $message { say $message.perl }
    }
    
    my $client = IO::Socket::Async.connect('localhost', 3333).then: {
        .result.write(Blob.new: 144);
    }
    
    await $client, $server;

It prints the following, and exits:

    Unhandled exception: Malformed UTF-8

In practice, having a server than can be crashed at will by any (even 
not-authenticated) client is of course LTA.
It seem the only way to prevent this, is to use .Supply(:bin) to work with 
Buf's, which is needlessly cumbersome for text-based protocols.

I tried to catch the exception in the following ways, to prevent it from 
exiting the program, but none had an effect:

1) CATCH or try/CATCH in a bunch of different places
2) Assigning to $*SCHEDULER.uncaught_handler
3) Specifying a :quit handler for both .tap's

Reply via email to