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

Blin 2020.08, round 1 #3850

Closed
2 tasks done
Altai-man opened this issue Aug 16, 2020 · 11 comments
Closed
2 tasks done

Blin 2020.08, round 1 #3850

Altai-man opened this issue Aug 16, 2020 · 11 comments
Assignees
Labels
blin Result of a regular ecosystem check with modules regressed, which must be fixed before release BLOCKER Preventing the next release of rakudo, or just needing attention before the release regression Issue did not exist previously

Comments

@Altai-man
Copy link
Member

Altai-man commented Aug 16, 2020

Blin results between 2020.07 (d0233dd) and HEAD (9d6d8dd):

  • Data::Dump – Fail, Bisected: c11f4b1

    Old Output
    ===> Searching for: Data::Dump
    ===> Found: Data::Dump:ver<v.0.0.11>:auth<github:tony-o> [via Zef::Repository::LocalCache]
    ===> Testing: Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    [Data::Dump] t/00-use.t ............. ok
    [Data::Dump] t/01-hash.t ............ ok
    [Data::Dump] t/02-obj.t ............. ok
    [Data::Dump] t/03-array.t ........... ok
    [Data::Dump] t/04-gist.t ............ ok
    [Data::Dump] t/05-skipmethods.t ..... ok
    [Data::Dump] t/06-match.t ........... ok
    [Data::Dump] t/07-obj-no-postfix.t .. ok
    [Data::Dump] t/08-override.t ........ ok
    [Data::Dump] All tests successful.
    [Data::Dump] Files=9, Tests=23, 20 wallclock secs ( 0.09 usr  0.02 sys + 17.57 cusr  1.16 csys = 18.84 CPU)
    [Data::Dump] Result: PASS
    ===> Testing [OK] for Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    ===> Installing: Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    ===> Install [OK] for Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    
    
    New Output
    ===> Searching for: Data::Dump
    ===> Found: Data::Dump:ver<v.0.0.11>:auth<github:tony-o> [via Zef::Repository::LocalCache]
    ===> Testing: Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    [Data::Dump] t/00-use.t ............. ok
    [Data::Dump] t/01-hash.t ............ ok
    [Data::Dump] # Failed test 'got expected data structure'
    [Data::Dump] # at t/02-obj.t line 25
    [Data::Dump] E :: (
    [Data::Dump]   $!private => 5.Int,
    [Data::Dump]   $!public => (Nil),
    [Data::Dump]   method Submethod+{is-hidden-from-backtrace}.new () returns Mu {...},
    [Data::Dump]   method e () returns Int {...},
    [Data::Dump]   method public () returns Mu {...},
    [Data::Dump]   method r () returns Mu {...},
    [Data::Dump]   method s () returns Mu {...},
    [Data::Dump] )
    [Data::Dump]   in block <unit> at t/02-obj.t line 25
    [Data::Dump] # You planned 3 tests, but ran 1
    [Data::Dump] # You failed 1 test of 1
    [Data::Dump] t/02-obj.t ............. 
    [Data::Dump] Dubious, test returned 1 (wstat 256, 0x100)
    [Data::Dump] Failed 3/3 subtests 
    [Data::Dump] t/03-array.t ........... ok
    [Data::Dump] t/04-gist.t ............ ok
    [Data::Dump] t/05-skipmethods.t ..... ok
    [Data::Dump] t/06-match.t ........... ok
    [Data::Dump] # Failed test 'got expected data structure'
    [Data::Dump] # at t/07-obj-no-postfix.t line 26
    [Data::Dump] E :: (
    [Data::Dump]   $!private => 5,
    [Data::Dump]   $!private2 => "hello",
    [Data::Dump]   $!public => (Nil),
    [Data::Dump]   method Submethod+{is-hidden-from-backtrace}.new () returns Mu {...},
    [Data::Dump]   method e () returns Int {...},
    [Data::Dump]   method public () returns Mu {...},
    [Data::Dump]   method r () returns Mu {...},
    [Data::Dump]   method s () returns Mu {...},
    [Data::Dump] )
    [Data::Dump]   in block <unit> at t/07-obj-no-postfix.t line 26
    [Data::Dump] # You planned 3 tests, but ran 1
    [Data::Dump] # You failed 1 test of 1
    [Data::Dump] t/07-obj-no-postfix.t .. 
    [Data::Dump] Dubious, test returned 1 (wstat 256, 0x100)
    [Data::Dump] Failed 3/3 subtests 
    [Data::Dump] # Failed test 'got expected data structure'
    [Data::Dump] # at t/08-override.t line 34
    [Data::Dump] E :: (
    [Data::Dump]   $!private => 10,
    [Data::Dump]   $!private2 => Str:hello,
    [Data::Dump]   $!public => (Nil),
    [Data::Dump]   BUILDALL ()
    [Data::Dump]   e ()
    [Data::Dump]   public ()
    [Data::Dump]   r ()
    [Data::Dump]   s ()
    [Data::Dump] )
    [Data::Dump]   in block <unit> at t/08-override.t line 34
    [Data::Dump] # You planned 3 tests, but ran 1
    [Data::Dump] # You failed 1 test of 1
    [Data::Dump] t/08-override.t ........ 
    [Data::Dump] Dubious, test returned 1 (wstat 256, 0x100)
    [Data::Dump] Failed 3/3 subtests 
    [Data::Dump] Test Summary Report
    [Data::Dump] -------------------
    [Data::Dump] t/02-obj.t           (Wstat: 256 Tests: 1 Failed: 1)
    [Data::Dump]   Failed test:  1
    [Data::Dump]   Non-zero exit status: 1
    [Data::Dump]   Parse errors: Bad plan.  You planned 3 tests but ran 1.
    [Data::Dump] t/07-obj-no-postfix.t (Wstat: 256 Tests: 1 Failed: 1)
    [Data::Dump]   Failed test:  1
    [Data::Dump]   Non-zero exit status: 1
    [Data::Dump]   Parse errors: Bad plan.  You planned 3 tests but ran 1.
    [Data::Dump] t/08-override.t      (Wstat: 256 Tests: 1 Failed: 1)
    [Data::Dump]   Failed test:  1
    [Data::Dump]   Non-zero exit status: 1
    [Data::Dump]   Parse errors: Bad plan.  You planned 3 tests but ran 1.
    [Data::Dump] Files=9, Tests=17, 25 wallclock secs ( 0.09 usr  0.01 sys + 18.04 cusr  1.12 csys = 19.26 CPU)
    [Data::Dump] Result: FAIL
    ===> Testing [FAIL]: Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    [Data::Dump] Failed to get passing tests, but continuing with --force-test
    ===> Installing: Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    ===> Install [OK] for Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
    
    
  • BSON – Fail, Bisected: 9d6d8dd

    Old Output
    ===> Searching for: BSON
    ===> Found: BSON:ver<0.11.6.1> [via Zef::Repository::LocalCache]
    ===> Testing: BSON:ver<0.11.6.1>
    [BSON] t/110-objectid.t .... ok
    [BSON] t/120-javascript.t .. ok
    [BSON] t/300-document.t .... ok
    [BSON] t/310-document.t .... ok
    [BSON] t/320-document.t .... ok
    [BSON] t/330-document.t .... ok
    [BSON] t/340-document.t .... ok
    [BSON] t/350-document.t .... ok
    [BSON] All tests successful.
    [BSON] Files=8, Tests=22, 100 wallclock secs ( 0.11 usr  0.03 sys + 65.02 cusr  3.96 csys = 69.12 CPU)
    [BSON] Result: PASS
    ===> Testing [OK] for BSON:ver<0.11.6.1>
    ===> Installing: BSON:ver<0.11.6.1>
    ===> Install [OK] for BSON:ver<0.11.6.1>
    
    
    New Output
    ===> Searching for: BSON
    ===> Found: BSON:ver<0.11.6.1> [via Zef::Repository::LocalCache]
    ===> Testing: BSON:ver<0.11.6.1>
    [BSON] t/110-objectid.t .... ok
    [BSON] t/120-javascript.t .. ok
    [BSON] t/300-document.t .... ok
    [BSON] t/310-document.t .... ok
    [BSON]     # Failed test 'Pid = 146407'
    [BSON]     # at t/320-document.t line 282
    [BSON]     # expected: '146407'
    [BSON]     #      got: '9150'
    [BSON]     # You failed 1 test of 24
    [BSON] # Failed test 'Document encoding decoding types'
    [BSON] # at t/320-document.t line 8
    [BSON] # You failed 1 test of 1
    [BSON] t/320-document.t .... 
    [BSON] Dubious, test returned 1 (wstat 256, 0x100)
    [BSON] Failed 1/1 subtests 
    [BSON] t/330-document.t .... ok
    [BSON] t/340-document.t .... ok
    [BSON] t/350-document.t .... ok
    [BSON] Test Summary Report
    [BSON] -------------------
    [BSON] t/320-document.t  (Wstat: 256 Tests: 1 Failed: 1)
    [BSON]   Failed test:  1
    [BSON]   Non-zero exit status: 1
    [BSON] Files=8, Tests=22, 62 wallclock secs ( 0.11 usr  0.03 sys + 57.75 cusr  3.18 csys = 61.07 CPU)
    [BSON] Result: FAIL
    ===> Testing [FAIL]: BSON:ver<0.11.6.1>
    [BSON] Failed to get passing tests, but continuing with --force-test
    ===> Installing: BSON:ver<0.11.6.1>
    ===> Install [OK] for BSON:ver<0.11.6.1>
    
    
Status Count Modules
Flapper 1 Algorithm::Trie::libdatrie
UnhandledException 1 Foo::�Foo
Fail 2 BSON Data::Dump
InstallableButUntested 7 HTTP::Server::Async IO::Socket::Async::SSL IRC::Client Log::Minimal Time::Duration Toaster Uzu
ZefFailure 9 Async::Workers Concurrent::BoundedChannel Cro::HTTP DateTime::TimeZone Games::BubbleBreaker Gnome::Gtk3 MongoDB PDF::Class Perl6::Ecosystem
MissingDependency 13 CSS::Module CSS::Selector::To::XPath DBIish::Pool DBIx::NamedQueries HTTP::Server::Middleware::JSON HTTP::Server::Router HTTP::Server::Router::YAML Hematite SCGI Task::Galaxy Termbox Terminal::Boxer Web
CyclicDependency 16 Algorithm::HierarchicalPAM Algorithm::LDA Algorithm::LibSVM CSS CSS::Properties Chart::Gnuplot Cro::HTTP::Session::Red Foo::Dependencies::A-on-B Foo::Dependencies::B-on-A Foo::Dependencies::Self Geo::Hash HTML::Canvas HTML::Canvas::To::PDF MeCab Red RedX::HashedPassword
AlwaysFail 359
OK 1099

This run started on 2020-08-16T17:27:03Z and finished in ≈8 hours.

@Altai-man Altai-man added regression Issue did not exist previously BLOCKER Preventing the next release of rakudo, or just needing attention before the release blin Result of a regular ecosystem check with modules regressed, which must be fixed before release labels Aug 16, 2020
@Altai-man
Copy link
Member Author

Ping @nwc10 . It seems 9d6d8dd has resulted in a regression, can you please check?

@nwc10
Copy link
Contributor

nwc10 commented Aug 17, 2020

I can't replicate the BSON failure. I run the test in a loop and see:

ok 1 - Document encoding decoding types
1..1
    ok 1 - Encoded document is correct
    ok 2 - a => 1234, int32
    ok 3 - b => -203.345, double
    ok 4 - v => 4295392664, int64
    ok 5 - Javascript code on $d<w>
    ok 6 - Code is same
    ok 7 - nest $d<abcdef><a1> = 10
    ok 8 - nest $d<abcdef><b1><q> = 255
    ok 9 - Javascript code on $d<w>
    ok 10 - Code is same
    ok 11 - $d<jss>.scope<nn> = 10
    ok 12 - UUID binary data ok
    ok 13 - Binary type is UUID
    ok 14 - Boolean False
    ok 15 - Boolean True
    ok 16 - Text ok
    ok 17 - A[[1]] = abc
    ok 18 - A[[2]] = 345
    ok 19 - Length of object id ok
    ok 20 - Pid = 32611
    ok 21 - Date and time ok
    ok 22 - Null not defined
    ok 23 - Regex ok
    ok 24 - Regex options ok
    1..24

but with different values for Pid = 32661 for each run.

The failure doesn't really make sense at all. If I understand the BSON code and tests correctly. The test is this:

  is $d<oid>.pid, $*PID, "Pid = $*PID";

assigned earlier here

  $d<oid> = $oid;

constructed like this

  my BSON::ObjectId $oid .= new;

which I think means that it hit this code:

  multi submethod BUILD ( ) {

    $!machine-id = md5((~$*KERNEL).encode)>>.fmt('%02x').join('');
    $!time = time;
    $!pid = $*PID;
    $!count = 0xFFFFFF.rand.Int;

    self!generate-oid;
  }

so the test failing seems to mean that $*PID changed.

Which makes no sense to me.

@Altai-man
Copy link
Member Author

I can replicate it reliably:

➜  ~ raku --version
This is Rakudo version 2020.07-64-g9d6d8dd7a built on MoarVM version 2020.07-16-g03d3e43fa
implementing Raku 6.d.
➜  ~ zef install BSON
===> Searching for: BSON
===> Testing: BSON:ver<0.11.6.1>
[BSON]     # Failed test 'Pid = 2576080'
[BSON]     # at t/320-document.t line 282
[BSON]     # expected: '2576080'
[BSON]     #      got: '10062'
[BSON]     # You failed 1 test of 24
[BSON] # Failed test 'Document encoding decoding types'
[BSON] # at t/320-document.t line 8
[BSON] # You failed 1 test of 1
===> Testing [FAIL]: BSON:ver<0.11.6.1>
Aborting due to test failure: BSON:ver<0.11.6.1> (use --force-test to override)
➜  ~ zef install BSON
===> Searching for: BSON
===> Testing: BSON:ver<0.11.6.1>
[BSON]     # Failed test 'Pid = 2576486'
[BSON]     # at t/320-document.t line 282
[BSON]     # expected: '2576486'
[BSON]     #      got: '10064'
[BSON]     # You failed 1 test of 24
[BSON] # Failed test 'Document encoding decoding types'
[BSON] # at t/320-document.t line 8
[BSON] # You failed 1 test of 1
===> Testing [FAIL]: BSON:ver<0.11.6.1>
Aborting due to test failure: BSON:ver<0.11.6.1> (use --force-test to override)
➜  ~ zef install BSON
===> Searching for: BSON
===> Testing: BSON:ver<0.11.6.1>
[BSON]     # Failed test 'Pid = 2576621'
[BSON]     # at t/320-document.t line 282
[BSON]     # expected: '2576621'
[BSON]     #      got: '10064'
[BSON]     # You failed 1 test of 24
[BSON] # Failed test 'Document encoding decoding types'
[BSON] # at t/320-document.t line 8
[BSON] # You failed 1 test of 1
===> Testing [FAIL]: BSON:ver<0.11.6.1>
Aborting due to test failure: BSON:ver<0.11.6.1> (use --force-test to override)
➜  ~

It seems that it creates an ObjectId without arguments, which populates $pid with $*PID, at https://github.com/MARTIMM/BSON/blob/master/lib/BSON/ObjectId.pm6#L116 and then when it tries to parse it back from BSON and compare with current $*PID, the result parsed back is wrong.

@nwc10
Copy link
Contributor

nwc10 commented Aug 17, 2020

I can't at all, which makes it rather hard for me to figure out what to do next. Which OS and which compiler were you testing with?

The only hint as to what the cause might be is that for the results you paste, got is expected >> 8

got expected
274ed0 274e
275066 2750
2750ed 2750

@Altai-man
Copy link
Member Author

➜  ~ uname -a
Linux localhost.localdomain 5.7.9-200.fc32.x86_64 #1 SMP Fri Jul 17 16:23:37 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
➜  ~ raku --version
This is Rakudo version 2020.07-64-g9d6d8dd7a built on MoarVM version 2020.07-16-g03d3e43fa
implementing Raku 6.d.
➜  ~ gcc --version
gcc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)

Blin uses debian image, I think, and could detect the same issue.

@nwc10
Copy link
Contributor

nwc10 commented Aug 18, 2020

Not a regression. (still a bug). I can replicate it on 2020.07:

nick@gcc122:~/Perl$ PATH=~/Sandpit/moar-Og/bin:~/Sandpit/moar-Og/share/perl6/site/bin:$PATH zef install BSON
===> Searching for: BSON
===> Searching for missing dependencies: OpenSSL, UUID
===> Testing: OpenSSL:ver<0.1.23>:auth<github:sergot>
[OpenSSL] # NETWORK_TESTING was not set
[OpenSSL] # NETWORK_TESTING was not set
===> Testing [OK] for OpenSSL:ver<0.1.23>:auth<github:sergot>
===> Testing: UUID:ver<1.0.0>:auth<github:retupmoca>
===> Testing [OK] for UUID:ver<1.0.0>:auth<github:retupmoca>
===> Testing: BSON:ver<0.11.6.1>
[BSON]     # Failed test 'Pid = 612060'
[BSON]     # at t/320-document.t line 282
[BSON]     # expected: '612060'
[BSON]     #      got: '38253'
[BSON]     # You failed 1 test of 24
[BSON] # Failed test 'Document encoding decoding types'
[BSON] # at t/320-document.t line 8
[BSON] # You failed 1 test of 1
===> Testing [FAIL]: BSON:ver<0.11.6.1>
Aborting due to test failure: BSON:ver<0.11.6.1> (use --force-test to override)
nick@gcc122:~/Perl$ PATH=~/Sandpit/moar-Og/bin:~/Sandpit/moar-Og/share/perl6/site/bin:$PATH rakudo-m --version
This is Rakudo version 2020.07 built on MoarVM version 2020.07
implementing Raku 6.d.

but I have to hack MoarVM to fake PIDs that are >65536:

nick@gcc122:~/Perl/MoarVM$ git diff
diff --git a/src/io/procops.c b/src/io/procops.c
index ff6fa515c..882eb6fdd 100644
--- a/src/io/procops.c
+++ b/src/io/procops.c
@@ -1065,7 +1065,7 @@ MVMint64 MVM_proc_getpid(MVMThreadContext *tc) {
 #ifdef _WIN32
     return _getpid();
 #else
-    return getpid();
+    return (getpid() << 8) | 0xDC;
 #endif
 }

I will try to figure out the case of the bug, but I don't think that it is a blocker.

@Altai-man
Copy link
Member Author

➜  ~ raku --version
This is Rakudo version 2020.06 built on MoarVM version 2020.06
implementing Raku 6.d.
➜  ~ zef install BSON
===> Searching for: BSON
===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json
===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json
===> Testing: BSON:ver<0.11.6.1>
===> Testing [OK] for BSON:ver<0.11.6.1>
===> Installing: BSON:ver<0.11.6.1>
➜  ~ rakubrew switch moar-2020.07
Switching to moar-2020.07
➜  ~ zef install BSON
===> Searching for: BSON
===> Searching for missing dependencies: OpenSSL, UUID
===> Testing: OpenSSL:ver<0.1.23>:auth<github:sergot>
[OpenSSL] # NETWORK_TESTING was not set
[OpenSSL] # NETWORK_TESTING was not set
===> Testing [OK] for OpenSSL:ver<0.1.23>:auth<github:sergot>
===> Testing: UUID:ver<1.0.0>:auth<github:retupmoca>
===> Testing [OK] for UUID:ver<1.0.0>:auth<github:retupmoca>
===> Testing: BSON:ver<0.11.6.1>
===> Testing [OK] for BSON:ver<0.11.6.1>
===> Installing: OpenSSL:ver<0.1.23>:auth<github:sergot>
===> Installing: UUID:ver<1.0.0>:auth<github:retupmoca>
===> Installing: BSON:ver<0.11.6.1>
➜  ~ raku --version
This is Rakudo version 2020.07 built on MoarVM version 2020.07
implementing Raku 6.d.
➜  ~

Cannot reproduce it. It starts to become weird. Am I and blin the only beings who see this? Are there some conditions necessary for it to work, why I don't get them while trying out many times?

@nwc10
Copy link
Contributor

nwc10 commented Aug 19, 2020

It is weird, but it will fail if the system it is running on happens to produce process IDs > 65535, and I don't know what OSes do that, and whether (for them) process IDs are sequential (so that long running machines end up getting into this state) or randomised (so that certain OSes immediately (mostly) start generating large process IDs.

But for the systems I 've tried, process IDs are consistently <= 65535, but I can replicate it if I patch more (as shown above) to make the return values from MVM_proc_getpid larger.

So, I then patched the test:

diff --git a/t/320-document.t b/t/320-document.t
index 8a56e53..b0e569a 100644
--- a/t/320-document.t
+++ b/t/320-document.t
@@ -20,6 +20,7 @@ subtest {
   my BSON::Binary $bin .= new( :data($uuid.Blob), :type(BSON::C-UUID) );

   my BSON::ObjectId $oid .= new;
+  is $oid.pid, $*PID, "Pid = $*PID";

   my DateTime $datetime .= new( DateTime.now.posix, :timezone($*TZ));

@@ -63,6 +64,7 @@ subtest {
   $d<str> = "String text";
   $d<array> = [ 10, 'abc', 345];
   $d<oid> = $oid;
+  is $d<oid>.pid, $*PID, "Pid = $*PID";
   $d<dtime> = $datetime;
   $d<null> = Any;
   $d<rex> = $rex;
@@ -251,7 +253,9 @@ subtest {

   # Fresh doc, load handcrafted data and decode into document
   #
+  is $d<oid>.pid, $*PID, "Pid = $*PID";
   $d .= new($etst);
+  is $d<oid>.pid, $*PID, "Pid = $*PID";

   is $d<a>, 1234, "a => $d<a>, int32";
   is $d<b>, -203.345, "b => $d<b>, double";

and I now see this:

===> Testing: BSON:ver<0.11.6.1>
[BSON]     # Failed test 'Pid = 6634204'
[BSON]     # at t/320-document.t line 258
[BSON]     # expected: '6634204'
[BSON]     #      got: '25914'
[BSON]     # Failed test 'Pid = 6634204'
[BSON]     # at t/320-document.t line 286
[BSON]     # expected: '6634204'
[BSON]     #      got: '25914'
[BSON]     # You failed 2 tests of 28
[BSON] # Failed test 'Document encoding decoding types'
[BSON] # at t/320-document.t line 8
[BSON] # You failed 1 test of 1
===> Testing [FAIL]: BSON:ver<0.11.6.1>

line 258 is that last is that I added - the call to $d .= new($etst); changes $d<oid>.pid

Chasing through the code

  1. that constructor is being called with $etst
  2. in turn, the relevant part of $etst is intialised as
    # 17
    BSON::C-OBJECTID,                           # 0x07
      0x6f, 0x69, 0x64, 0x00,                   # 'oid'
      $oid.oid.List,
  1. realise that I fail to figure out where List gets its data, but
  2. The various BUILD methods end up calling this
  #-----------------------------------------------------------------------------
  # Generate object id. All data is little endian encoded.
  method !generate-oid ( ) {

    my @numbers = ();

    # Time in 4 bytes => no substr needed
    for $!time.fmt('%08x').comb(/../)[3...0] -> $hexnum {
      @numbers.push: :16($hexnum);
    }

    # Machine id in 3 bytes
    for $!machine-id.fmt('%6.6s').comb(/../)[2...0] -> $hexnum {
      @numbers.push: :16($hexnum);
    }

    # Process id in 2 bytes
    for $!pid.fmt('%04x').comb(/../)[1,0] -> $hexnum {
      @numbers.push: :16($hexnum);
    }

    # Result of count truncated to 3 bytes
    for $!count.fmt('%08x').comb(/../)[2...0] -> $hexnum {
      @numbers.push: :16($hexnum);
    }

    $!oid .= new(@numbers);
  }

and that is truncating process IDs to two bytes, even when they are larger than two bytes. The code (or the regression tests) wrongly assume that process IDs are always <= 65535.

I don't know why, and I don't think that it's essential for "BSON" that it stores the process ID. The spec that that test links to -- https://docs.mongodb.com/manual/reference/method/ObjectId/ -- says

Returns a new ObjectId value. The 12-byte ObjectId value consists of:

a 4-byte timestamp value, representing the ObjectId’s creation, measured in seconds since the Unix epoch
a 5-byte random value
a 3-byte incrementing counter, initialized to a random value

so what the spec has as "5-byte random value" the BSON code is implementing as "3 byte machine ID" followed by "2 byte process ID". Which is fine (as long as it's random enough) but clearly doesn't "quite" pass its own tests when process IDs are larger than 2 bytes. Ooops. But it's only the test that are failing - truncating the PID to 2 bytes is still conformat with that spec.

(What I do not know is whether that spec has changed, and it used to say "machine ID" and "PID", and then 10gen got a rude awakening when someone reported that PIDs can be large)

@Altai-man
Copy link
Member Author

Marking Data::Dump as done, as there is a PR available and the overall changes seem sensible.

PID above 65535 is easily possible in Linux, see https://stackoverflow.com/a/6294196/6700717
For example, on default Fedora I see 4194304 as output of /proc/sys/kernel/pid_max, which is a maximum for 64 bit system, I guess.

The code (or the regression tests) wrongly assume that process IDs are always <= 65535

This seems like the module's fault. I wonder how was it not exposed earlier, this sounds just unbelievable.

And the second time this module got bisected to a completely different commit... Thanks for your time taken to do the investigation, @nwc10 ! Closing.

@jnthn
Copy link
Member

jnthn commented Aug 20, 2020

This seems like the module's fault.

Did an issue get opened on the module linking to this information?

@Altai-man
Copy link
Member Author

@jnthn MARTIMM/BSON#32 <- sure, I wouldn't close it otherwise.

japhb added a commit to japhb/BSON that referenced this issue Jun 30, 2021
See MARTIMM#32 and
rakudo/rakudo#3850 (comment)
for more details, but in essence:

This library has split the ObjectID 5-byte "random value" field as described
in https://docs.mongodb.com/manual/reference/method/ObjectId/ into two
subfields: a 3-byte machine name hash, and a 2-byte process ID.  Unfortunately
since most modern Linux/*nix systems use larger process IDs, this simply takes
the first two bytes of the actual PID.  That would not in itself be a problem,
except that the tests check that the actual PID can be extracted back out of
the ObjectID; these tests fail if the real PID happens to be larger than 65535.

Since the spec doesn't actually *require* any structure to the "random value"
field, just stop testing for this round tripping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blin Result of a regular ecosystem check with modules regressed, which must be fixed before release BLOCKER Preventing the next release of rakudo, or just needing attention before the release regression Issue did not exist previously
Projects
None yet
Development

No branches or pull requests

4 participants