Closed tmpolaczyk closed 5 years ago
@tmpolaczyk putting a lock on FILE_CONTENTS
just for it to be testable looks a little overkill but it won't do any harm any way, so it sounds like a reasonable compromise to me.
This is a race condition, not a data race, so any kind of synchronization around the global mutable state won't solve the problem, well, a Mutex will, but that's not necessary at all, I've created #195 which should solve it by making the global mutable state thread local.
Solved by #195
Using the following command to run tests until they fail:
We can see a failure in
loaders::toml::tests::test_load_config_from_file
:This is a race condition so it may take a while to replicate the bug.
The reason is the use of unsafe code in
config/loaders/toml.rs
:A simple fix would be to load configuration from a string instead.
To safely mutate global variables in Rust, use
RwLock
.