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


Hi,

recently when trying to parallelise fetching multiple websites with
LWP::Simple over https (LWP::Simple utilizes IO::Socket::SSL module which
in turn uses NativeCall to execute openssl functions from the openssl c
library) I've encountered rakudo crashes. Here is golfed version of my
issue:


getenv should be threadsafe according to:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01

# Non parallelised version works as expected:
$ perl6 -e 'use NativeCall; sub getenv(Str) is native returns Str { * };
say getenv("HOME")'
/home/ubuntu

# Lets try it parallelised (this time worked):
$ perl6 -e 'use NativeCall; sub getenv(Str) is native returns Str { * };
await start { getenv("HOME") } xx 2'
$ echo $?
0
# More promises bigger chance of hitting the issue:
$ perl6 -e 'use NativeCall; sub getenv(Str) is native returns Str { * };
await start { getenv("HOME") } xx 25'
Cannot invoke this object (REPR: Null)
  in block <unit> at -e line 1


Camelia from freenode:

21:07 <Rotwang> m: use NativeCall; sub getenv(Str) is native returns Str {
* }; await start { getenv("HOME") } xx 5
21:07 <camelia> rakudo-moar 4bb47d: OUTPUT«(signal SEGV)»

21:08 <Rotwang> m: use NativeCall; sub getenv(Str) is native returns Str {
* }; await start { getenv("HOME") } xx 20
21:08 <camelia> rakudo-moar 4bb47d: OUTPUT«Memory allocation failed; could
not allocate 21080 bytes␤Memory allocation failed; could not allocate 21080
bytes␤»

21:09 <Rotwang> m: use NativeCall; sub getenv(Str) is native returns Str {
* }; await start { getenv("HOME") } xx 15
21:09 <camelia> rakudo-moar 4bb47d: OUTPUT«Could not spawn thread:
errorcode -1␤»

Issue doesn't happen every time, so at times it may be hard to reproduce,
however increased promises quantity should increase the odds.

Reply via email to