Upstream libgit2 builtin sha256 may have race condition

Abierto
#1,255 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
git, rust
Área
devtools

Línea de trabajo

Ejecuta cargo test con unstable-sha256 habilitado y la funcionalidad http deshabilitada, centrándote en indexer::tests::indexer_sha256 y en el fallo de src/test.rs. Inspecciona el archivo upstream src/util/hash/rfc6234/sha224-256.c, especialmente el addTemp estático; el trabajo estará terminado cuando las ejecuciones simultáneas de pruebas ya no produzcan discrepancias en los hashes de los objetos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

upstream

This was found in

during cargo test which the test harness libtest is multi-threaded.

thread 'indexer::tests::indexer_sha256' (11949) panicked at src/test.rs:36:14:
called `Result::unwrap()` on an `Err` value: Error { code: -33, klass: 9, message: "object hash mismatch - expected 7991f5e7c0692696aec4fdf250571006878b2667a3123fbdb5329653591af542 but got 831eed201a25d1677172d9c5e6cc953308062f5e007f5e9a28c0e38250c17d8b" }

Observed them failed on different toolchains and platforms, and only when unstable-sha256 is enabled with http feature deactivated.

After some investigation, I found that in upstream libgit2. It use a static addTemp which doesn't have any thread-safe mechanism around it: https://github.com/libgit2/libgit2/blob/d23f18fd881b8c5bb5e7a7abfcbc71ddf0c9a5ea/src/util/hash/rfc6234/sha224-256.c#L86-L91

Combined with the "without http feature" finding, I think that means the GIT_SHA256_BUILTIN is not thread safe. This is not too hard to reproduce by adjust test running in a fairly amount of threads (i.e., 16 or 32) and rerunning the entire test suite a couple of times.

cc https://github.com/rust-lang/git2-rs/pull/1206

Lenguaje dominante
Rust
Estrellas
2.1k
Forks
470
Merge medio
2 d 17 h
PR fusionados (30 d)
18

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/git2-rs

Todos los issues de rust-lang/git2-rs

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.