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

Negative overflow in Str.index $startpos #4466

Closed
p6rt opened this issue Aug 11, 2015 · 16 comments
Closed

Negative overflow in Str.index $startpos #4466

p6rt opened this issue Aug 11, 2015 · 16 comments

Comments

@p6rt
Copy link

p6rt commented Aug 11, 2015

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

Searchable as RT125784$

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

From @AlexDaniel

Code​:
say index 'xxy', 'y',
-999999999999999999999999999999999999999999999999999999999999999;
say index 'xxy', 'y',
-9999999999999999999999999999999999999999999999999999999999999999;

Result​:
Nil
2

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

From @labster

This is actually a Moarbug​:

labster​: m​: use nqp; say nqp​::index('xxy', 'y', -999999999999999999999999999999999999999999999999999999999999999)
camelia​: rakudo-moar a32c14​: OUTPUT«-1␤»
labster​: j​: use nqp; say nqp​::index('xxy', 'y', -999999999999999999999999999999999999999999999999999999999999999)
camelia​: rakudo-jvm a32c14​: OUTPUT«2␤»

On Mon Aug 10 17​:47​:12 2015, alex.jakimenko@​gmail.com wrote​:

Code​:
say index 'xxy', 'y',
-999999999999999999999999999999999999999999999999999999999999999;
say index 'xxy', 'y',
-9999999999999999999999999999999999999999999999999999999999999999;

Result​:
Nil
2

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

From @lizmat

Fixed with 14939e39d24541cc29fd12, tests added with e29df31, closable

On 11 Aug 2015, at 02​:47, Alex Jakimenko (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Code​:
say index 'xxy', 'y',
-999999999999999999999999999999999999999999999999999999999999999;
say index 'xxy', 'y',
-9999999999999999999999999999999999999999999999999999999999999999;

Result​:
Nil
2

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

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

@p6rt
Copy link
Author

p6rt commented Aug 11, 2015

From @lizmat

Fixed with 14939e39d24541cc29fd12, tests added with e29df31, closable

On 11 Aug 2015, at 02​:47, Alex Jakimenko (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Code​:
say index 'xxy', 'y',
-999999999999999999999999999999999999999999999999999999999999999;
say index 'xxy', 'y',
-9999999999999999999999999999999999999999999999999999999999999999;

Result​:
Nil
2

@p6rt
Copy link
Author

p6rt commented Aug 13, 2015

From @usev6

On Tue Aug 11 01​:15​:38 2015, elizabeth wrote​:

Fixed with 14939e39d24541cc29fd12, tests added with e29df31, closable

Great, ticket closed.

@p6rt
Copy link
Author

p6rt commented Aug 13, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 22, 2015

From @usev6

It looks like the overflow still happens. (Expected result is different nowadays, since negative start positions are disallowed (see rakudo/rakudo@fa3ce116e3).

See also http://irclog.perlgeek.de/perl6/2015-11-21#i_11577908

$ perl6-m -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Nil

$ perl6-j -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Position in index out of range. Is​: -9223372036854775807, should be in 0..3
  in block <unit> at -e​:1

Actually thrown at​:
  in block <unit> at -e​:1

There are fudged tests ('todo') for this in S32-str/index.t and S32-str/rindex.t.

Also nqp-m and nqp-j still behave differently​:

$ nqp-m -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
-1

$ nqp-j -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
2

1 similar comment
@p6rt
Copy link
Author

p6rt commented Nov 22, 2015

From @usev6

It looks like the overflow still happens. (Expected result is different nowadays, since negative start positions are disallowed (see rakudo/rakudo@fa3ce116e3).

See also http://irclog.perlgeek.de/perl6/2015-11-21#i_11577908

$ perl6-m -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Nil

$ perl6-j -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Position in index out of range. Is​: -9223372036854775807, should be in 0..3
  in block <unit> at -e​:1

Actually thrown at​:
  in block <unit> at -e​:1

There are fudged tests ('todo') for this in S32-str/index.t and S32-str/rindex.t.

Also nqp-m and nqp-j still behave differently​:

$ nqp-m -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
-1

$ nqp-j -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
2

@p6rt
Copy link
Author

p6rt commented Nov 22, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

From @lizmat

The problem is really in the implementation of nqp​::unbox_i on JVM​:

$ perl6-j -e 'use nqp; nqp​::unbox_i(-99999999999999999999999999)’
(no error)

$ 6 'use nqp; nqp​::unbox_i(-99999999999999999999999999)

'
Cannot unbox 87 bit wide bigint into native integer
  in block <unit> at -e​:1

Liz

On 22 Nov 2015, at 10​:55, Christian Bartolomaeus via RT <bugs-comment@​bugs6.perl.org> wrote​:

It looks like the overflow still happens. (Expected result is different nowadays, since negative start positions are disallowed (see rakudo/rakudo@fa3ce116e3).

See also http://irclog.perlgeek.de/perl6/2015-11-21#i_11577908

$ perl6-m -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Nil

$ perl6-j -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Position in index out of range. Is​: -9223372036854775807, should be in 0..3
in block <unit> at -e​:1

Actually thrown at​:
in block <unit> at -e​:1

There are fudged tests ('todo') for this in S32-str/index.t and S32-str/rindex.t.

Also nqp-m and nqp-j still behave differently​:

$ nqp-m -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
-1

$ nqp-j -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
2

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

From @lizmat

Commit 292336995df5220f93ec4c5c makes the use of *any* bigint as position in index/rindex a Failure. Tests have been adapted accordingly. I think this ticket can be closed.

On 22 Nov 2015, at 10​:55, Christian Bartolomaeus via RT <bugs-comment@​bugs6.perl.org> wrote​:

It looks like the overflow still happens. (Expected result is different nowadays, since negative start positions are disallowed (see rakudo/rakudo@fa3ce116e3).

See also http://irclog.perlgeek.de/perl6/2015-11-21#i_11577908

$ perl6-m -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Nil

$ perl6-j -e 'say index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999)'
Position in index out of range. Is​: -9223372036854775807, should be in 0..3
in block <unit> at -e​:1

Actually thrown at​:
in block <unit> at -e​:1

There are fudged tests ('todo') for this in S32-str/index.t and S32-str/rindex.t.

Also nqp-m and nqp-j still behave differently​:

$ nqp-m -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
-1

$ nqp-j -e 'nqp​::say(nqp​::index("xxy", "y", -999999999999999999999999999999999999999999999999999999999999999))'
2

@p6rt
Copy link
Author

p6rt commented Apr 17, 2016

From @coke

Christian, can you double check again? Thanks.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Apr 17, 2016

From @usev6

The problems regarding negative overflows seem to be fixed. All tests for this ticket are passing. I'm closing this ticket as 'resolved'.

For the related discussion (different behavior of nqp​::index with negative $startpos between Moar and JVM) I opened a new ticket​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127913

1 similar comment
@p6rt
Copy link
Author

p6rt commented Apr 17, 2016

From @usev6

The problems regarding negative overflows seem to be fixed. All tests for this ticket are passing. I'm closing this ticket as 'resolved'.

For the related discussion (different behavior of nqp​::index with negative $startpos between Moar and JVM) I opened a new ticket​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127913

@p6rt
Copy link
Author

p6rt commented Apr 17, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant