Data race on `LOGGER.buf_console` between `set_buf_console` and the logger
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- rust
- Domaine
- operating-systems
Piste de recherche
Start with awkernel_lib/src/logger.rs and trace set_buf_console alongside Logger::enabled, Logger::log, and Logger::flush; then check the buffered logger setup in applications/awkernel_services/src/buffered_logger.rs. Verify how console registration and logging can overlap across CPUs, including the set_raw_console path. Done when the shared logger state is accessed without a data race and the boot-time raw console behavior is understood.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
awkernel_lib::logger::set_buf_console writes LOGGER.buf_console without synchronization while other CPUs read it through log::info! and the other logging macros. This is a data race, which is undefined behavior in Rust.
This was found during the review of #799.
Details
LOGGER is a static mut in awkernel_lib/src/logger.rs:
static mut LOGGER: Logger = Logger {
raw_console: None,
buf_console: None,
};
- Writer:
set_buf_consoleruns(*ptr).buf_console = Some(logger)with no lock and no atomic operation. The buffered logger task (applications/awkernel_services/src/buffered_logger.rs) calls it, so it runs after all CPUs have started to execute tasks. - Readers:
Logger::enabled,Logger::log, andLogger::flushreadself.buf_consoleon every CPU each time a logging macro is called, also with no synchronization.
Possible effect
Option<&'static dyn Log> is two words: a data pointer and a vtable pointer. The write can be two stores. A CPU that reads between them can get the new data pointer with the old vtable pointer, and log.log(record) then calls through an invalid vtable.
The window is a few instructions and the write happens once at boot, so this is unlikely to occur in practice. I have not reproduced it.
Proposed fix
buf_console is written once and never changed afterward, so a separate AtomicBool that publishes it is enough:
set_buf_consolewrites the pointer, and then sets the flag withOrdering::Release.Loggerloads the flag withOrdering::Acquire, and readsbuf_consoleonly when the flag is set.
With this, no CPU reads the pointer while it is written.
Related
set_raw_console writes raw_console in the same way. It is called from console::register_console, which appears to run during early boot before the other CPUs start. Whether it can run concurrently with logging on another CPU should be checked as part of this issue.
- Langage dominant
- Rust
- Étoiles
- 282
- Forks
- 12
- Merge moyen
- 2 j 9 h
- PR mergées (30 j)
- 28
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de tier4/awkernel
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
Les mainteneurs répondent en général sous 2 jours
-
Deadlock in ixgbeOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de tier4/awkernel
Issues similaires
-
bug ui
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
userFRM/egui-charts#3363 ·
Les mainteneurs répondent en général sous 1 jour
-
ada documentation mobile report
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
physicsdolphin/nv-uefi-unlocker#254 · 2 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
kindraywind/rustnarok-client#1382 ·
Les mainteneurs répondent en général sous 1 jour
-
area:accessibility bug good first issue help wanted priority:p3-low size:small
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
NecturaLabs/Canopy#209 ·
-
CLI config custom-model enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour