Data race on `LOGGER.buf_console` between `set_buf_console` and the logger
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- operating-systems
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 282
- Fork
- 12
- Merge medio
- 2g 9h
- PR unite (30g)
- 28
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tier4/awkernel
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
-
Deadlock in ixgbeAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di tier4/awkernel
Issue simili
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
flashbots/panetiere#46 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jlcodes99/cockpit-tools#3190 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Feyisara2108/stellargive#1376 ·
I maintainer di solito rispondono entro 1 giorno
-
area:post bug effort:medium P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno