Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Low priority: creating a new pilot leaks about 1 KB

Abierto
#7,900 0 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo

Línea de trabajo

Start at init_new_pilot and pilot_set_start_campaign in managepilot.cpp, then inspect cutscene_init and parse_cutscene_table in cutscenes.cpp for ownership and cleanup behavior. Check the file-list ownership returned by cf_get_file_list in cfilesystem.cpp. Build with the issue's AddressSanitizer and leak-check flags, create a new pilot, and verify that LeakSanitizer reports no creation-related leaks.

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

Descripción

Low priority. A small, one-time leak per new pilot (about 1 KB). It would take a very large number of pilot creations in one session to matter; filing it so it's on record.

Problem

Creating a new pilot leaks a little memory each time:

  • init_new_pilot calls cutscene_init() again (managepilot.cpp:159), which clears Cutscenes without freeing each entry's description and then reloads the table (cutscenes.cpp:212 and 158). Every reload leaks the previous descriptions; it also registers cutscene_close with atexit again.
  • pilot_set_start_campaign gets a list of campaign file names from cf_get_file_list and never frees it (managepilot.cpp:206).

Steps to reproduce

  1. Build master (12a36dc1a) with -DGCC_ENABLE_ADDRESS_SANITIZER=ON -DGCC_ENABLE_LEAK_CHECK=ON.
  2. Start with retail data and an empty preferences folder, create a new pilot, reach the main hall, and quit normally.
  3. Read LeakSanitizer's report.

Expected vs. actual behavior

Expected: no leaks from creating a pilot.

Actual: LeakSanitizer reports 875 bytes in 10 allocations from parse_cutscene_table (cutscenes.cpp:158, via cutscene_init) and 11 bytes from cf_get_file_list (cfilesystem.cpp:2142, via pilot_set_start_campaign).

Proposed fixes

Ranked by simplicity, then maintainability, then thoroughness.

  1. Call cutscene_close() at the top of cutscene_init() before clearing the list, and free the campaign file list at the end of pilot_set_start_campaign.
  2. Make cutscene_info::description an SCP_string so the vector owns it and no manual free is needed, and register the atexit only once.
  3. Have the pilot code reset only the cutscenes' viewable flags instead of re-running the whole table load, which also saves re-parsing the tables on every new pilot.
Lenguaje dominante
C++
Estrellas
488
Forks
184
Merge medio
2 d 8 h
PR fusionados (30 d)
41

Preparar el entorno

Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 scp-fs2open/fs2open.github.com

Todos los issues de scp-fs2open/fs2open.github.com

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.