Skip Menu |
Report information
Id: 133057
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: comdog <brian.d.foy [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: brian d foy <brian.d.foy [...] gmail.com>
Date: Tue, 3 Apr 2018 20:41:21 -0400
To: rakudobug [...] perl.org
Subject: Odd interaction of HTTP::UserAgent and Promises
Download (untitled) / with headers
text/plain 2.4k
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 Show quoted text
>;
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
From: brian d foy <brian.d.foy [...] gmail.com>
Date: Tue, 3 Apr 2018 20:46:55 -0400
To: perl6-bugs-followup [...] perl.org
Subject: Re: [perl #133057] AutoReply: Odd interaction of HTTP::UserAgent and Promises
Download (untitled) / with headers
text/plain 112b
Ah, there's even an HTTP::UserAgent issue for this I think: https://github.com/sergot/http-useragent/issues/191
Subject: Re: [perl #133057] Odd interaction of HTTP::UserAgent and Promises
To: perl6-compiler [...] perl.org
CC: bugs-bitbucket [...] rt.perl.org
From: Simon Proctor <simon.proctor [...] gmail.com>
Date: Wed, 04 Apr 2018 01:30:27 +0000
Download (untitled) / with headers
text/plain 2.9k
Looks to me like one of the sites is redirecting to an https page and you don't have IO::Socket::SSL installed. 



On Wed, 4 Apr 2018, 1:42 am brian d foy, <perl6-bugs-followup@perl.org> wrote:
Show quoted text
# 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
From: Simon Proctor <simon.proctor [...] gmail.com>
Date: Wed, 04 Apr 2018 01:34:20 +0000
CC: bugs-bitbucket [...] rt.perl.org
To: perl6-compiler [...] perl.org
Subject: Re: [perl #133057] Odd interaction of HTTP::UserAgent and Promises
Download (untitled) / with headers
text/plain 3.4k
There are also issues with libssl (which I think the IO::Socket::SSL module calls using Native Call) and threads. 

At the moment the only threads safe https client is the Cro one, I believe. 

Sorry I can't be more help, 2am insomnia should really be sleeping. 

On Wed, 4 Apr 2018, 2:30 am Simon Proctor, <simon.proctor@gmail.com> wrote:
Show quoted text
Looks to me like one of the sites is redirecting to an https page and you don't have IO::Socket::SSL installed. 



On Wed, 4 Apr 2018, 1:42 am brian d foy, <perl6-bugs-followup@perl.org> wrote:
# 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
Subject: Re: [perl #133057] Odd interaction of HTTP::UserAgent and Promises
To: perl6-bugs-followup [...] perl.org
From: brian d foy <brian.d.foy [...] gmail.com>
Date: Tue, 3 Apr 2018 23:27:30 -0400
Download (untitled) / with headers
text/plain 161b
The error message isn't useful because you get that no matter what happens. It's really the IO::Socket::SSL is not thread safe. But, I'd not expect a segfault.


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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org