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

md5() crashes with Cannot unbox negative bigint... #33

Closed
pheix opened this issue Dec 10, 2022 · 4 comments
Closed

md5() crashes with Cannot unbox negative bigint... #33

pheix opened this issue Dec 10, 2022 · 4 comments

Comments

@pheix
Copy link

pheix commented Dec 10, 2022

Looks like smth was broken with 289a042:

Digest:ver<0.8.2>:auth<Lucien Grondin>
[kostas@webtech-omen core-perl6]$ zef install "Digest:ver<0.8.2>"
===> Searching for: Digest:ver<0.8.2>
===> Testing: Digest:ver<0.8.2>
===> Testing [OK] for Digest:ver<0.8.2>
===> Installing: Digest:ver<0.8.2>
[kostas@webtech-omen core-perl6]$ raku -MDigest -e "md5('158.389').say";
Blob:0x<1D 83 F5 B9 D9 6A F1 A2 5F 36 38 42 31 03 BE 1B>
[kostas@webtech-omen core-perl6]$ zef uninstall Digest
===> Uninstalled from inst#/opt/rakudo/rakudo-star-2022.04/share/perl6/site
Digest:ver<0.8.2>:auth<Lucien Grondin>

[kostas@webtech-omen core-perl6]$ zef install "Digest:ver<0.9.0>"
===> Searching for: Digest:ver<0.9.0>
===> Testing: Digest:ver<0.9.0>
===> Testing [OK] for Digest:ver<0.9.0>
===> Installing: Digest:ver<0.9.0>
[kostas@webtech-omen core-perl6]$ raku -MDigest -e "md5('158.389').say";
Cannot unbox negative bigint into native unsigned integer
  in sub infix:«<<<» at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/08D38337202051EEADB24BAFC11F43DA5C064BAA (Digest) line 6
  in sub md5-block at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/08D38337202051EEADB24BAFC11F43DA5C064BAA (Digest) line 35
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/08D38337202051EEADB24BAFC11F43DA5C064BAA (Digest) line 47
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/08D38337202051EEADB24BAFC11F43DA5C064BAA (Digest) line 43
  in block <unit> at -e line 1

Looks relevant to #27 and #28.

It crashes on latest version as well:

[kostas@webtech-omen core-perl6]$ zef install Digest
===> Searching for: Digest
===> Testing: Digest:ver<0.23.1>
===> Testing [OK] for Digest:ver<0.23.1>
===> Installing: Digest:ver<0.23.1>
[kostas@webtech-omen core-perl6]$ raku -MDigest::MD5 -e "md5('158.389').say";
Cannot unbox negative bigint into native unsigned integer
  in block  at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 15
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 10
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 4
  in block <unit> at -e line 1
@grondilu
Copy link
Owner

grondilu commented Dec 10, 2022

It crashes on latest version as well:

Indeed it does on my machine too. Not sure why the tests don't crash.

PS. Very weirdly, it works fine when adding an alphabetic prefix:

$ raku -MDigest::MD5 -e "md5('x158.389').say";
Blob:0x<4C 99 79 A4 E8 CE 77 81 A1 99 A3 65 E4 03 C2 98>

@pheix
Copy link
Author

pheix commented Dec 10, 2022

😿

[kostas@webtech-omen utils]$ raku -MDigest::MD5 -e "md5('158.389x').say";
Blob:0x<6E 80 44 F2 2A 16 E8 1D AC 6C 76 4C A5 B4 81 59>
[kostas@webtech-omen utils]$ raku -MDigest::MD5 -e "md5('158x389').say";
Blob:0x<77 13 9D 7E D3 0D AD 17 3C 12 72 64 E3 3A 8E 59>
[kostas@webtech-omen utils]$ raku -MDigest::MD5 -e "md5('158,389').say";
Blob:0x<AE 65 F5 3E 1B 3B 9E B6 B8 69 08 CE 85 FC A9 DE>
[kostas@webtech-omen utils]$ raku -MDigest::MD5 -e "md5('158.389').say";
Cannot unbox negative bigint into native unsigned integer
  in block  at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 15
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 10
  in sub md5 at /opt/rakudo/rakudo-star-2022.04/share/perl6/site/sources/09B6112E2626A59F08A91D5D4762CC9F145C0515 (Digest::MD5) line 4
  in block <unit> at -e line 1

@grondilu
Copy link
Owner

I'll just add a mod 2**32 operation at the necessary step

grondilu added a commit that referenced this issue Dec 10, 2022
@pheix
Copy link
Author

pheix commented Dec 10, 2022

🚀 update, let me check on my test base...

UPD: Perfect:

[kostas@webtech-omen utils]$ zef install https://github.com/grondilu/libdigest-raku.git
===> Testing: Digest:ver<0.24.0>
===> Testing [OK] for Digest:ver<0.24.0>
===> Installing: Digest:ver<0.24.0>
[kostas@webtech-omen core-perl6]$ time raku -MDigest::MD5 -e "for (1..1000000) { md5((0..10000).rand.Str) }";

real	21m59.710s
user	21m53.113s
sys	0m1.368s

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

No branches or pull requests

2 participants