[SPAM:##] [perl #126014] Too many repetitions with xx operator causes out of memory; should it work lazily?

2018-04-07 Thread Aleks-Daniel Jakimenko-Aleksejev via RT
Tests in
https://github.com/perl6/roast/commit/b320464868d3b8da98c090ddc4b0d57604683e13

Closing

On 2018-03-10 11:25:06, jan-olof.hen...@bredband.net wrote:
> On Wed, 22 Feb 2017 03:59:05 -0800, elizabeth wrote:
> > > On 22 Feb 2017, at 12:41, jn...@jnthn.net via RT  > > follo...@perl.org> wrote:
> > > On Sat, 30 Apr 2016 03:42:00 -0700, alex.jakime...@gmail.com wrote:
> > >> OK, I said that it only segfaults on 32-bit systems, but I was
> > >> wrong.
> > >>
> > >> Code:
> > >> 42 xx (2 ** 62)
> > >>
> > >> Result:
> > >> Segmentation fault
> > >>
> > > This is patched in MoarVM HEAD just now and no longer SEGVs
> > > (reports
> > > the array is too long to allocate). So, no longer a SEGV bug.
> > >
> > > However, I'm a bit surprised that xx does not work lazily, and
> > > actually makes such a huge array up-front. Not sure if we want to
> > > re-
> > > purpose the ticket for that; I'll remove the SEGV from the title,
> > > however, since that is resolved.
> >
> > Ah, yes, I remember we discussed this. I’ll make it a Seq, although
> > the question then becomes: should it be lazy or not? If it is not
> > lazy, we would just be postponing the exception in some cases.
> >
> >
> > Liz
>
> Fixed with commit
>
https://github.com/rakudo/rakudo/commit/1eb7b1f796214870b53c7ed055907cb29076dc78


[perl #126014] Too many repetitions with xx operator causes out of memory; should it work lazily?

2018-03-10 Thread Jan-Olof Hendig via RT
On Wed, 22 Feb 2017 03:59:05 -0800, elizabeth wrote:
> > On 22 Feb 2017, at 12:41, jn...@jnthn.net via RT  > follo...@perl.org> wrote:
> > On Sat, 30 Apr 2016 03:42:00 -0700, alex.jakime...@gmail.com wrote:
> >> OK, I said that it only segfaults on 32-bit systems, but I was
> >> wrong.
> >>
> >> Code:
> >> 42 xx (2 ** 62)
> >>
> >> Result:
> >> Segmentation fault
> >>
> > This is patched in MoarVM HEAD just now and no longer SEGVs (reports
> > the array is too long to allocate). So, no longer a SEGV bug.
> >
> > However, I'm a bit surprised that xx does not work lazily, and
> > actually makes such a huge array up-front. Not sure if we want to re-
> > purpose the ticket for that; I'll remove the SEGV from the title,
> > however, since that is resolved.
> 
> Ah, yes, I remember we discussed this.  I’ll make it a Seq, although
> the question then becomes: should it be lazy or not?  If it is not
> lazy, we would just be postponing the exception in some cases.
> 
> 
> Liz

Fixed with commit 
https://github.com/rakudo/rakudo/commit/1eb7b1f796214870b53c7ed055907cb29076dc78
 


Re: [perl #126014] [SEGV] Too many repetitions with xx operator cause a segfault ("x" xx 9999999999)

2017-02-22 Thread Elizabeth Mattijsen
> On 22 Feb 2017, at 12:41, jn...@jnthn.net via RT 
>  wrote:
> On Sat, 30 Apr 2016 03:42:00 -0700, alex.jakime...@gmail.com wrote:
>> OK, I said that it only segfaults on 32-bit systems, but I was wrong.
>> 
>> Code:
>> 42 xx (2 ** 62)
>> 
>> Result:
>> Segmentation fault
>> 
> This is patched in MoarVM HEAD just now and no longer SEGVs (reports the 
> array is too long to allocate). So, no longer a SEGV bug.
> 
> However, I'm a bit surprised that xx does not work lazily, and actually makes 
> such a huge array up-front. Not sure if we want to re-purpose the ticket for 
> that; I'll remove the SEGV from the title, however, since that is resolved.

Ah, yes, I remember we discussed this.  I’ll make it a Seq, although the 
question then becomes: should it be lazy or not?  If it is not lazy, we would 
just be postponing the exception in some cases.


Liz

[perl #126014] [SEGV] Too many repetitions with xx operator cause a segfault ("x" xx 9999999999)

2017-02-22 Thread jn...@jnthn.net via RT
On Sat, 30 Apr 2016 03:42:00 -0700, alex.jakime...@gmail.com wrote:
> OK, I said that it only segfaults on 32-bit systems, but I was wrong.
> 
> Code:
> 42 xx (2 ** 62)
> 
> Result:
> Segmentation fault
> 
This is patched in MoarVM HEAD just now and no longer SEGVs (reports the array 
is too long to allocate). So, no longer a SEGV bug.

However, I'm a bit surprised that xx does not work lazily, and actually makes 
such a huge array up-front. Not sure if we want to re-purpose the ticket for 
that; I'll remove the SEGV from the title, however, since that is resolved.


Re: xx operator

2006-09-28 Thread Fagyal Csongor

A. Pagaltzis wrote:


I have the following code:

class MyStupidString {
   method repeatit(Str $string, Int $repeat) {
   say $string xx $repeat;
   my $add = $string xx $repeat;
   say $add;
   }

};

my $obj = MyStupidString.new;
$obj.repeatit("---",10);



Interestingly, it says:
> pugs test2.p6
--
--- --- --- --- --- --- --- --- --- ---


What am I misunderstanding here?
   



The `xx` operator. That's list-repeat, not string-repeat.

In Perl 5 terms, the code you wrote is:

   sub repeatit {
   my ( $string, $repeat ) = @_;
   my @res = ( $string ) x $repeat;
   print @res;
   my $add = "@res";
   print $add;
   }

which should make it obvious what is going on.
 


Thank you and Juerd.

It was indeed a misunderstanding, I though "x" changed to "xx" in Perl6 
for some reasons...



Now is the first time I write some Perl6 code that I actually run, too 
:) It is *really* enjoyable. Feels like "this is how Perl should really 
look like", and it is so DWIM I can hardly believe it. Kudos to all who 
helped to make it happen!


- Fagzal


Re: xx operator

2006-09-28 Thread Juerd
Fagyal Csongor skribis 2006-09-28 15:11 (+0200):
>say $string xx $repeat;

List context.

>my $add = $string xx $repeat;

Item context, for a list repetition operator. Doesn't really make sense,
and I think a warning or error message would be more appropriate.

I think you meant either:

my @add = $string xx $repeat;

or:

my $add = $string x $repeat;

Or perhaps:

my $add = [ $string xx $repeat ];
# This is what your current code does, but I think it's best if Perl
# enforced that you be explicit about the [].
-- 
korajn salutojn,

  juerd waalboer:  perl hacker  <[EMAIL PROTECTED]>  
  convolution: ict solutions and consultancy <[EMAIL PROTECTED]>


Re: xx operator

2006-09-28 Thread A. Pagaltzis
> I have the following code:
> 
> class MyStupidString {
> method repeatit(Str $string, Int $repeat) {
> say $string xx $repeat;
> my $add = $string xx $repeat;
> say $add;
> }
> 
> };
> 
> my $obj = MyStupidString.new;
> $obj.repeatit("---",10);
> 
> 
> 
> Interestingly, it says:
>  > pugs test2.p6
> --
> --- --- --- --- --- --- --- --- --- ---
> 
> 
> What am I misunderstanding here?

The `xx` operator. That's list-repeat, not string-repeat.

In Perl 5 terms, the code you wrote is:

sub repeatit {
my ( $string, $repeat ) = @_;
my @res = ( $string ) x $repeat;
print @res;
my $add = "@res";
print $add;
}

which should make it obvious what is going on.
-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl


xx operator

2006-09-28 Thread Fagyal Csongor

Hi,

I have the following code:

class MyStupidString {
   method repeatit(Str $string, Int $repeat) {
   say $string xx $repeat;
   my $add = $string xx $repeat;
   say $add;
   }

};

my $obj = MyStupidString.new;
$obj.repeatit("---",10);



Interestingly, it says:
> pugs test2.p6
--
--- --- --- --- --- --- --- --- --- ---


What am I misunderstanding here? Or is this a Pugs bug?

I am using pugs 6.2.12

- Fagzal