I thought an "interesting" part of the change was actually how they made a 50% chance work for the extra read. They select across a closed channel twice -- and it results in a mostly even distribution of chance.
for i := 0; i < 100000; i++ {
select {
case <-closedChan:
a++
case <-closedChan:
b++
case <-closedChan:
c++
case <-closedChan:
d++
}
}
Results in an almost even distribution across the select choices!https://play.golang.org/p/cnAXBEZJm2B
(fixed playground link)
Re:Go 1.11 Beta 1 is released
by zimpenfish on Wednesday June 27, 2018 @01:38AM
(#17406007)
You're printing `b` three times in that Playground which makes it a look skewed.
a: 25100
b: 25080
c: 25080
d: 25080
vs a: 24973
b: 25010
c: 25013
d: 25004
Re:Go 1.11 Beta 1 is released
by cup-of-tea on Wednesday June 27, 2018 @02:57AM
(#17406253)
So it's deterministic. I got the same numbers.
On the Playground or on your PC? The Playground has an execution cache, so the same input code always gives the same (thus "deterministic") result.
Re:Go 1.11 Beta 1 is released
by cup-of-tea on Wednesday June 27, 2018 @05:11AM
(#17406766)
Ah OK, it was on the playground. Is it deterministic when not cached?
It is not deterministic on playground if it is not cached.
You can add dummy code to the file to break free from the cache.
Adding some white space also does the trick
> or changing hashtable iteration order.
This is a builtin feature of Go.
Interesting. In contrast, the JavaScript standard says Map object iteration must return values in original insertion order. Firefox used to randomize the iteration order (to help find bugs), but (surprise!) it broke some web content. :(
Re:Go 1.11 Beta 1 is released
by omarforgotpwd on Wednesday June 27, 2018 @12:39AM
(#17405798)
I don't think this is to shake out bugs. This is just to have a more random pseudo-random number generator so that applications using the crypto package for encryption will be more secure.
Re:Go 1.11 Beta 1 is released
by staticassertion on Wednesday June 27, 2018 @01:16AM
(#17405934)
Why would it do it randomly then? Just read in the extra byte if you want extra entropy.
Starting at the link above, click on the #21915 in the commit message, which takes you to https://golang.org/issue/21915.
Re:Go 1.11 Beta 1 is released
by staticassertion on Wednesday June 27, 2018 @01:46AM
(#17406023)
So for no reason, it is about forcing code not to rely on the behavior.
There's a reason given.
Re:Go 1.11 Beta 1 is released
by staticassertion on Wednesday June 27, 2018 @01:44PM
(#17410193)
As in, the reason has nothing to do with entropy, and it is just about breaking code relying on an unspecified behavior.
Re:Go 1.11 Beta 1 is released
by omarforgotpwd on Wednesday June 27, 2018 @02:21PM
(#17410506)
One really easy way to break any encryption scheme is to crack the random number generator. This works because random number generators are deterministic and you can get them to output the exact same stream of random numbers as they did before if you have the same seed / state. This is presumably about making the output of the random number generator harder to predict.
Re:Go 1.11 Beta 1 is released
by staticassertion on Wednesday June 27, 2018 @08:25PM
(#17413080)
> This is presumably about making the output of the random number generator harder to predict.
Randomly deciding to add an extra byte of entropy only adds 1 bit of entropy. Adding the extra byte always adds 8 bits of entropy.
There is no cryptographic reason to do this. It is just to break assumptions about the API.
crypto: randomly read an extra byte of randomness in some places.
https://go-review.googlesource.com/c/go/+/64451
Firefox has a similar testing feature called "chaos mode" that tries to shake out bugs by doing things like randomly forcing short file or socket reads or changing hashtable iteration order. Due to the increased chance of buggy behavior or performance issues, this isn't the sort of thing you would do in production (unless you're on Netflix's chaos engineering team. :)