CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.61k stars 4.17k forks source link

[CAUSE FOUND] Memory leak and crash when falling asleep with a radio on #32968

Closed ampersand55 closed 5 years ago

ampersand55 commented 5 years ago

Describe the bug

If you sleep with a radio in your inventory turned on, there is a memory leak and game crash.

Note that I'm referring to the tool with item id "radio" / "radio_on". Not a vehicle stereo or mp3 player.

Steps To Reproduce

  1. Make a new player
  2. Create a radio via the debug menu (and battery, ambien, rollmat, earplugs if needed)
  3. Turn on the radio
  4. Sleep

Before sleeping open task manager or other memory monitoring program to check memory usage.

Expected behavior

Screenshots

Versions and configuration

- OS: Windows
    - OS Version: 10.0 1607
- Game Version: 0.D-6237-g7682029 [64-bit]
- Graphics Version: Tiles
- Mods loaded: [
    Dark Days Ahead [dda]
]

Additional context

For other players:

If you are affected by this and autosave before sleeping you can turn off/remove the radio from the .sav file with a text-editor.

perryprog commented 5 years ago

I can't reproduce this after a 9 hour sleep. Memory sticked around at 634MB or about 2 to 4% usage. Could be OS specific?

- OS: macOS
    - OS Version: Name: macOS; Version: 10.14.6; Build: 18G84; 
- Game Version: 0.D-6239-ga1ada1a67e [64-bit]
- Graphics Version: Tiles
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food]
]
ampersand55 commented 5 years ago

Maybe. I don't currently have access to another OS to check.

New info: The radio itself causes the memory leak.

Simply waiting in-game with with the radio on makes the memory spike.

https://i.imgur.com/CIYmDcu.png

CRASH LOG FILE: config/crash.log
VERSION: 0.D-6237-g7682029
TYPE: Signal
MESSAGE: SIGSEGV: Segmentation fault
STACK TRACE:
    @0x59D9A5[cataclysm-tiles.exe+0x19D9A5]
    @0x59E472[cataclysm-tiles.exe+0x19E472]
    SMPEG_error+0x4B034@0xF37480[cataclysm-tiles.exe+0xB37480]
    _C_specific_handler+0x96@0x7FFEC8256606[ntdll.dll+0x96606]
    _chkstk+0x11D@0x7FFEC826A58D[ntdll.dll+0xAA58D]
    RtlImageNtHeaderEx+0x483@0x7FFEC81FFD23[ntdll.dll+0x3FD23]
    KiUserExceptionDispatcher+0x3A@0x7FFEC82696FA[ntdll.dll+0xA96FA]
    @0xD44FFB[cataclysm-tiles.exe+0x944FFB]
    @0xD468E5[cataclysm-tiles.exe+0x9468E5]
    @0x826C13[cataclysm-tiles.exe+0x426C13]
    IMG_LoadWEBP_RW+0x2E0CC1@0x1309FB1[cataclysm-tiles.exe+0xF09FB1]
    @0x7EC965[cataclysm-tiles.exe+0x3EC965]
    @0x7B038D[cataclysm-tiles.exe+0x3B038D]
    @0x7B11C2[cataclysm-tiles.exe+0x3B11C2]
    @0xC31865[cataclysm-tiles.exe+0x831865]
    @0x6BB56A[cataclysm-tiles.exe+0x2BB56A]
    IMG_LoadWEBP_RW+0x575DD8@0x159F0C8[cataclysm-tiles.exe+0x119F0C8]
    @0x4013ED[cataclysm-tiles.exe+0x13ED]
    @0x4014FB[cataclysm-tiles.exe+0x14FB]
    BaseThreadInitThunk+0x14@0x7FFEC58C84D4[KERNEL32.DLL+0x84D4]
    RtlUserThreadStart+0x21@0x7FFEC822E851[ntdll.dll+0x6E851]
Qrox commented 5 years ago

Cannot reproduce on windows 10. Can you attach a save that reproduces the problem? I do noticed that radios do not seem to be producing sound and draining battery any more, but that's probably a separate issue.

ampersand55 commented 5 years ago

Sure.

Test world.zip

Qrox commented 5 years ago

Nope, still cannot reproduce on the exact version as shown in your crash log.

ampersand55 commented 5 years ago

Peculiar...

The problem persists for me after downloading a new version via the CDDA launcher.

Thanks for trying anyway.

ZhilkinSerg commented 5 years ago

Can you send us your config folder please?

ampersand55 commented 5 years ago

I noticed that the error disappeared when deleting and resetting the config folder, so I did a little testing and it turns out that @'s soundpack caused the error.

@'s soundpack has 3-7 mb, 18-43 seconds long .wav files playing inaudible_chatter as radio sound effects, which probably caused the memory spike when played in succession while sleeping/waiting.

From @'s soundpack effects.json

{
  "type": "sound_effect",
  "id": "radio",
  "variant": "inaudible_chatter",
  "volume": 90,
  "files": [
    "effects/misc/radio_inaudible_chatter_1.wav",
    "effects/misc/radio_inaudible_chatter_2.wav",
    "effects/misc/radio_inaudible_chatter_3.wav",
    "effects/misc/radio_inaudible_chatter_4.wav"
  ]
},

You could close this as it's not a fault within the main game, but I think limiting the game to only play 1-3 sound effects of a specific "variant" at a time would be good. I've also noticed that thunder gets extremely loud when sleeping and several thunder strikes are played at the same time.

@'s soundpack links: