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


I have this little program where I want to fetch web thingys
concurrently. There's a problem with the combination of HTTP::UserAgent
and Promises although I don't know which one doesn't work:

    #!perl6

    use HTTP::UserAgent;
    my $ua = HTTP::UserAgent.new: :useragent<chrome_linux>;

    my @urls = <
        http://www.perl.org
        http://www.perl6.org
        http://www.yahoo.com
        >;

    loop {
        my @promises;
        for @urls -> $url {
            @promises.push: Promise
                .start({ $ua.get: $url })
                .then({ put "Got {.result.^name}" });
            }
        await @promises;
        }

Running this program sometimes works a little and often if fails in
diverse and curious ways. I couldn't get it to fail unless I used a
Promise:

    $ perl6 cycle.p6
    Got HTTP::Response
    Segmentation fault: 11

    $ perl6 cycle.p6
    Got HTTP::Response
    Illegal instruction: 4

    $ perl6 cycle.p6
    Got HTTP::Response
    An operation first awaited:
      in block <unit> at cycle.p6 line 20

    Died with the exception:
        Tried to get the result of a broken Promise
          in block  at cycle.p6 line 18

        Original exception:
            Please install IO::Socket::SSL in order to fetch https
sites: Failed to seek in filehandle: 22
              in method get-connection at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 350
              in method get-connection at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 343
              in method request at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 156
              in method request at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 176
              in method get at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 102
              in method get at
/Users/brian/Desktop/lib/HTTP/UserAgent.pm (HTTP::UserAgent) line 105
              in block  at cycle.p6 line 17

    $ perl6 cycle.p6
    Got HTTP::Response
    moar(77217,0x70001052c000) malloc: *** error for object
0x7fd7b89a4af0: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    Abort trap: 6

Here's the setup

    $ perl6 -v
    This is Rakudo Star version 2018.01 built on MoarVM version 2018.01
    implementing Perl 6.c.
    $ uname -a
    Darwin . 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54
PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

Reply via email to