Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Low priority: creating a new pilot leaks about 1 KB

Aperta
#7,900 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C++
Stelle
488
Fork
184
Merge medio
2g 9h
PR unite (30g)
40

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scp-fs2open/fs2open.github.com

Tutte le issue di scp-fs2open/fs2open.github.com

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.