Data race or race condition during exiting/joining a thread
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
- 30/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- c, wasm
- Área
- operating-systems
Línea de trabajo
Comienza con libc-top-half/musl/src/thread/pthread_create.c, especialmente con la ruta de salida del recuento de hilos y la desasignación de la pila citadas en el informe. Compila y ejecuta el reproductor wasm32-wasi-threads proporcionado bajo wasmtime, y luego rastrea la contabilidad de los hilos y el comportamiento de join/exit. Se considera terminado cuando el programa de estrés finaliza normalmente e imprime "ok!" sin una limpieza insegura de la pila.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This is a program which spawns N threads. Each thread will then, M times, spawn a thread and join the thread. This is intended to exercise concurrently spawning threads.
#include <pthread.h>
#include <stdio.h>
#include <assert.h>
#define N 10
#define M 10000
static void *another_child(void *arg) {
return arg;
}
static void* child(void *arg) {
pthread_t child;
for (int i = 0; i < M; i++) {
int rc = pthread_create(&child, NULL, another_child, NULL);
if (rc != 0)
perror("failed to create thread");
rc = pthread_join(child, NULL);
if (rc != 0)
perror("failed to join thread");
}
return arg;
}
int main() {
pthread_t children[N];
for (int i = 0; i < N; i++) {
int rc = pthread_create(&children[i], NULL, child, NULL);
if (rc != 0)
perror("failed to spawn thread");
}
for (int i = 0; i < N; i++) {
int rc = pthread_join(children[i], NULL);
if (rc != 0)
perror("failed to join thread");
}
printf("ok!\n");
}
This is then run with:
$ clang foo.c -o foo.wasm -O2 --target=wasm32-wasi-threads -pthread -Wl,--import-memory,--export-memory,--stack-first,-zstack-size=$((10 << 20)),--max-memory=$((3 << 30))
$ wasmtime run --wasi-modules experimental-wasi-threads --disable-cache --wasm-features threads -- ./foo.wasm
This will produce no output and exit with status zero, but not expectedly. The ok! is not printed at the end of the main function. The reason for this appears to be that this exit is reached because a thread confuses itself as the last remaining thread.
I did a bit of poking to see if this could be fixed. The __tl_lock() function, for example, is aliased to a dummy_0 in many files. I wasn't able to fix it, however.
While looking around in this file, however, I also noticed that free is used to deallocate a thread stack which I don't believe is correct because the thread stack is in use by the thread calling free, which means that after the memory has been deallocated some stack management may still be happening which may modify the free'd memory. I haven't run into this myself, though, and commenting out the free did not fix my issue above.
cc @abrown
- Lenguaje dominante
- C
- Estrellas
- 1k
- Forks
- 268
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 20
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de WebAssembly/wasi-libc
-
wasip2: enabling O_APPEND with fcntl reuses the old positional output stream and overwrites the fileAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
WebAssembly/wasi-libc#919 ·
Los mantenedores suelen responder en 1 día
-
wasip2/wasip3: reads never see data appended to a file after reaching EOFPosiblemente ocupada @libsmol la tomó hace 25 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 61/100
WebAssembly/wasi-libc#889 ·
Los mantenedores suelen responder en 1 día
-
Contradicting `SOL_TCP` and `SOL_UDP` definition for p1Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
WebAssembly/wasi-libc#855 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
MIT licensing state is unhealthyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
WebAssembly/wasi-libc#815 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
WebAssembly/wasi-libc#809 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de WebAssembly/wasi-libc
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
389ds/389-ds-base#8152 ·
Los mantenedores suelen responder en 2 días
-
meta:feature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
mpv-player/mpv#18855 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[FIX]: File Tree in appAbiertobug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition rootPosiblemente ocupada @tuhaihe la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/cloudberry#2356 ·
Los mantenedores suelen responder en 2 días