UB/crashes with libedit
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Comienza en readline_s_set_output() y clear_rl_outstream(), y luego sigue cómo rl_initialize() almacena rl_outstream en libedit. Reproduce el fallo con libedit y musl libc, e investiga la ruta relacionada de rl_instream mencionada en el informe. Se considera terminado cuando la salida de readline ya no accede a un FILE* cerrado y se evita el fallo informado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
the code mentions compatibility with libedit, however the following happens in practice (e.g. while using irb from ruby 2.5.0):
- libedit initializes internal copy of rl_outstream
FILE*pointer during rl_initialize()
e = el_init_internal(rl_readline_name, rl_instream, rl_outstream, ...). this saves the current rl_outstream inel->el_outfile.
from that point on, libedit only operates on el_outfile in itsEditLine*context. - in this module, clear_rl_outstream() is called from readline_s_set_output() which fclose()s rl_outstream. then rl_outstream gets a fresh
FILE*assigned - however this does not affect libedit which continues using its el_outfile struct member. - next attempt to write anything to the output file via readline API causes a segfault - at least with musl libc, which is stricter in regards to UB.
probably this was never caught because the developers used glibc where the fclose() FILE structure happened to stay in RAM at the same address. or maybe the new FILE was allocated at the exact same address. it's 100% reproducible using libedit (latest release) and musl libc, and likely when using address sanitizer even on glibc.
it's likely that rl_instream handling has the same bug, but i only investigated the crash i actually got.
arguably it's a bug of libedit to supply rl_outstream but then use it only for initialization - but it appears nobody else was closing the FILE behind libedit's back so far, else it would be fixed in latest libedit version.
(background: i was about to update ruby from 2.5.0 to a newer version in my distro sabotage linux and noticed irb crashing, so i wanted to fix it before switching to a more modern version, so someone who needs to use the old version for whatever reason can go back in commit history and produce a 100% working version).
- Lenguaje dominante
- C
- Estrellas
- 14
- Forks
- 7
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
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 ruby/readline-ext
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
ruby/readline-ext#20 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
ruby/readline-ext#17 ·
Todos los issues de ruby/readline-ext
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
bradcypert/plum#53 ·
-
Component: GLib
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Status: Opened
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
nextbsd/nextbsd-userland#285 ·