aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-11-07 01:54:58 -0500
committerAndrew Kelley <andrew@ziglang.org>2022-11-10 14:35:57 -0500
commite40c38d258800cd555a4b53af8c711886ca0d38d (patch)
treeb86544249ad5a7ed4ee405defe126da9edd1172c /lib/std/testing.zig
parent59af6417bbb93a2cca453d930320217a970040bd (diff)
downloadzig-e40c38d258800cd555a4b53af8c711886ca0d38d.tar.gz
zig-e40c38d258800cd555a4b53af8c711886ca0d38d.zip
Sema: avoid breaking hash contract when instantiating generic functions
* Add tagName to Value which behaves like @tagName. * Add hashUncoerced to Value as an alternative to hash when we want to produce the same hash for value that can coerce to each other. * Hash owner_decl instead of module_fn in Sema.instantiateGenericCall since Module.Decl.Index is not affected by ASLR like *Module.Fn was, and also because GenericCallAdapter.eql was already doing this. * Use Value.hashUncoerced in Sema.instantiateGenericCall because GenericCallAdapter.eql uses Value.eqlAdvanced to compare args, which ignores coersions. * Add revealed missing cases to Value.eqlAdvanced. Without these changes, we were breaking the hash contract for monomorphed_funcs, and were generating different hashes for values that compared equal. This resulted in a 0.2% chance when compiling self-hosted of producing a different output, which depended on fingerprint collisions of hashes that were affected by ASLR. Normally, the different hashes would have resulted in equal checks being skipped, but in the case of a fingerprint collision, the truth would be revealed and the compiler's behavior would diverge.
Diffstat (limited to 'lib/std/testing.zig')
0 files changed, 0 insertions, 0 deletions