Data race on `LOGGER.buf_console` between `set_buf_console` and the logger
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- rust
- Domínio
- operating-systems
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Rust
- Estrelas
- 282
- Forks
- 12
- Merge médio
- 2d 9h
- PRs com merge (30d)
- 28
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de tier4/awkernel
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
Mantenedores costumam responder em até 2 dias
-
Deadlock in ixgbeAberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
Mantenedores costumam responder em até 2 dias
Todas as issues de tier4/awkernel
Issues semelhantes
-
marketing
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
flashbots/panetiere#46 · 1 comentário ·
Mantenedores costumam responder em até 5 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
jlcodes99/cockpit-tools#3190 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Feyisara2108/stellargive#1376 ·
Mantenedores costumam responder em até 1 dia
-
area:post bug effort:medium P7 source:agent
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia