scp-fs2open / scp-fs2open/fs2open.github.com

free on non-malloc'd address when terminating due to audio device failure

Open
#1,253 1 comment 0 reactions 0 assignees View on GitHub
bug discussion sound
Dominant language
C++
Stars
487
Forks
184
Avg merge
3d 9h
Merged PRs (30d)
44

Description

Ok, this isn't that serious of a bug, as it probably only happens right before the game would have been exiting anyway. Basically, if you try to run the game itself when no sound device is present, without -nosound, it errors with a message about not being able to open a playback device, and then AddressSanitizer reports the free non-malloc'd memory issue below. The ASan issue is what should at least be investigated, as it could possibly highlight some other memory issue that hasn't been noticed yet. The ALCplaybackAlsa error is expected and not the issue here. I imagine we have a device close call in a shutdown routine that doesn't confirm the device was ever actually opened.
```cliff@kvmny08:/usr/share/games/freespace2> ./fs2_open_3_7_5_20170221_san_x64-DEBUG
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
=================================================================
==15100== ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x0000040b1010
#0 0x7f40ab98b90a in __interceptor_free (/usr/lib64/libasan.so.0+0x1590a)
#1 0x7f40ab7312a1 in alcOpenDevice (/usr/lib64/libopenal.so.1+0x262a1)
#2 0x12b5c4c in ds_init() /usr/share/games/fs2source/fs2_open/code/sound/ds.cpp:388
#3 0x12ca33a in snd_init() /usr/share/games/fs2source/fs2_open/code/sound/sound.cpp:143
#4 0x80b156 in game_init() /usr/share/games/fs2source/fs2_open/freespace2/freespace.cpp:1770
#5 0x81b583 in game_main(int, char**) /usr/share/games/fs2source/fs2_open/freespace2/freespace.cpp:6861
#6 0x81eed8 in actual_main(int, char**) /usr/share/games/fs2source/fs2_open/freespace2/freespace.cpp:8105
#7 0x81f0cb in main /usr/share/games/fs2source/fs2_open/freespace2/freespace.cpp:8150
#8 0x7f40a86046e4 in __libc_start_main (/lib64/libc.so.6+0x206e4)
SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free
==15100== ABORTING
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.