[Git][reproducible-builds/reproducible-website][master] docs/stable-outputs: Add Rust section
kpcyrd (@kpcyrd)
gitlab at salsa.debian.org
Thu Jan 8 17:49:22 UTC 2026
kpcyrd pushed to branch master at Reproducible Builds / reproducible-website
Commits:
07558472 by kpcyrd at 2026-01-08T18:49:09+01:00
docs/stable-outputs: Add Rust section
- - - - -
1 changed file:
- _docs/stable_outputs.md
Changes:
=====================================
_docs/stable_outputs.md
=====================================
@@ -8,6 +8,8 @@ Data structures such as [Perl
hashes](http://perldoc.perl.org/functions/keys.html), [Python
dictionaries](https://docs.python.org/library/stdtypes.html#mapping-types-dict)
and [sets](https://docs.python.org/library/stdtypes.html#set-types-set-frozenset),
+[Rust std::collections::HashMap and
+std::collections::Hashset](https://doc.rust-lang.org/stable/std/collections/index.html#iterators),
or [Ruby Hash objects](https://ruby-doc.org/core/Hash.html) will list their keys
in a different order on every run to limit [algorithmic complexity
attacks](http://perldoc.perl.org/perlsec.html#Algorithmic-Complexity-Attacks).
@@ -47,6 +49,28 @@ Python users can similarly set the environment variable
When set to a given integer value, orders in dictionaries and sets will be the
same on every run.
+Rust
+----
+
+When iterating over the keys or entries of a `HashMap`, the order is [explicitly
+undefined](https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html)
+and depends on a random seed:
+
+> By default, HashMap uses a hashing algorithm selected to provide resistance
+> against HashDoS attacks. The algorithm is randomly seeded, and a reasonable
+> best-effort is made to generate this seed from a high quality, secure source
+> of randomness provided by the host without blocking the program.
+
+Iterating over a HashMap can cause reproducible builds issue when:
+
+- done inside a `build.rs` file
+- done in a function that's directly or indirectly called from a `build.rs` file
+
+This can often be fixed by replacing `HashMap` with
+[`BTreeMap`](https://doc.rust-lang.org/stable/std/collections/index.html#use-a-btreemap-when).
+There's a [real-world example](https://github.com/gtk-rs/gtk-rs-core/pull/1840)
+of how this was fixed.
+
General
-------
Beware that the [locale settings]({{ "/docs/locales/" | relative_url }})
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/07558472aa8236846cc42b543ca71e55a963428c
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/07558472aa8236846cc42b543ca71e55a963428c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20260108/9e4d3aa9/attachment.htm>
More information about the rb-commits
mailing list