Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite Loop with missing second arg on .subst-mutate #4984

Closed
p6rt opened this issue Jan 3, 2016 · 7 comments
Closed

Infinite Loop with missing second arg on .subst-mutate #4984

p6rt opened this issue Jan 3, 2016 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 3, 2016

Migrated from rt.perl.org#127135 (status was 'resolved')

Searchable as RT127135$

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @zoffixznet

Consider this code that is missing the second argument for .subst-mutate method and the error it generates​:

<Zoffix> m​: my $foo = '42'; $foo.subst-mutate​: /^'ba'/;
<camelia> rakudo-moar b5cb00​: OUTPUT«Memory allocation failed; could not allocate 19776 bytes␤»

What's happening is instead of getting the .subst-mutate from Str type, the missing arg causes us to get the one from Cool type​: https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L267

The Cool then stringifies the argument and attempts to call .subst-mutate again, with same args, restarting the infinite loop​: https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L273

The number of args in Cool should be detected and error generated.

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @lizmat

On 03 Jan 2016, at 19​:12, Zoffix Znet (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zoffix Znet
# Please include the string​: [perl #​127135]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127135 >

Consider this code that is missing the second argument for .subst-mutate method and the error it generates​:

<Zoffix> m​: my $foo = '42'; $foo.subst-mutate​: /^'ba'/;
<camelia> rakudo-moar b5cb00​: OUTPUT«Memory allocation failed; could not allocate 19776 bytes␤»

What's happening is instead of getting the .subst-mutate from Str type, the missing arg causes us to get the one from Cool type​: https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L267

The Cool then stringifies the argument and attempts to call .subst-mutate again, with same args, restarting the infinite loop​: https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L273

The number of args in Cool should be detected and error generated.

Fixed with 7d4cdbcdd5fce287afc32 . Since there are apparently *NO* spectests for Str.subst-mutate whatsover, I’m leaving the testing as low hanging fruit for someone else.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @LLFourn

There is no mention of subst-mutate in the design docs. Should I still
write tests in roast?

LL

On Mon, Jan 4, 2016 at 8​:52 AM Elizabeth Mattijsen <liz@​dijkmat.nl> wrote​:

On 03 Jan 2016, at 19​:12, Zoffix Znet (via RT) <
perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zoffix Znet
# Please include the string​: [perl #​127135]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127135 >

Consider this code that is missing the second argument for .subst-mutate
method and the error it generates​:

<Zoffix> m​: my $foo = '42'; $foo.subst-mutate​: /^'ba'/;
<camelia> rakudo-moar b5cb00​: OUTPUT«Memory allocation failed; could not
allocate 19776 bytes␤»

What's happening is instead of getting the .subst-mutate from Str type,
the missing arg causes us to get the one from Cool type​:
https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L267

The Cool then stringifies the argument and attempts to call
.subst-mutate again, with same args, restarting the infinite loop​:
https://github.com/rakudo/rakudo/blob/8c001e0a8fc4aacc93eb4327d30071b00f9699fa/src/core/Cool.pm#L273

The number of args in Cool should be detected and error generated.

Fixed with 7d4cdbcdd5fce287afc32 . Since there are apparently *NO*
spectests for Str.subst-mutate whatsover, I’m leaving the testing as low
hanging fruit for someone else.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @lizmat

On 04 Jan 2016, at 11​:51, Lloyd Fournier <lloyd.fourn@​gmail.com> wrote​:

There is no mention of subst-mutate in the design docs. Should I still write tests in roast?

Well, subst-mutate is *not* used inside of the core itself, so I can only assume it is intended to be user-facing. So yes, please add tests for it in roast, in a new file as to easily keep it apart should that be needed after all.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 29, 2018

From @zoffixznet

On Mon, 04 Jan 2016 03​:00​:00 -0800, elizabeth wrote​:

On 04 Jan 2016, at 11​:51, Lloyd Fournier <lloyd.fourn@​gmail.com>
wrote​:

There is no mention of subst-mutate in the design docs. Should I
still write tests in roast?

Well, subst-mutate is *not* used inside of the core itself, so I can
only assume it is intended to be user-facing. So yes, please add
tests for it in roast, in a new file as to easily keep it apart should
that be needed after all.

Liz

There's a bunch of tests for it now and I marked the one that tests this bug in Raku/roast@6c54594

@p6rt p6rt closed this as completed Jan 29, 2018
@p6rt
Copy link
Author

p6rt commented Jan 29, 2018

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant