-
Notifications
You must be signed in to change notification settings - Fork 275
Description
My understanding is that log
relies on atomics to implement some of its functionality, especially set_logger()
and set_max_level()
.
It seems there is an internal "fake" AtomicUsize
on platforms that do not provide atomics, with the assumption that no such architectures are multicore:
Lines 451 to 454 in 5359483
// Any platform without atomics is unlikely to have multiple cores, so | |
// writing via Cell will not be a race condition. | |
#[cfg(not(target_has_atomic = "ptr"))] | |
unsafe impl Sync for AtomicUsize {} |
However this assumption does not hold on the RP2040 MCU, which features two Cortex-M0+ (ARMv6-M) cores.
I am not sure this actually currently results in unsoundness because it is not yet clear to me whether the instances of AtomicUsize
are actually used in ways that could result in race conditions on these architectures.
I suppose leveraging portable-atomic on architectures that do not provide atomics could help fix this, if this is an acceptable dependency for log
, which would only be required on such architectures.
For context, we at Ariel OS are building an embedded OS which, among many other things, abstracts over log
and makes it easily usable on many processor architectures, making this easy to test.