Jump to content

OpenAL assertion on exit


Recommended Posts

Hi,

when exiting pyrogenesis_dbg, nearly every time I get this error:

...
TIMER| shutdown CNetLogManager: 4.8 us
TIMER| shutdown I18N: 7.32 us
OpenAL error: Invalid Operation; called from al_buf_free (#1)
snd_mgr.cpp(127): Assertion failed: "0"
udbg_bfd_init: loading symbols from ./pyrogenesis_dbg.
Assertion failed: "0"
Location: snd_mgr.cpp:127 (al_ReportError)

Call stack:

(0x0849b3f4) ldbg.cpp:99 debug_DumpStack(wchar_t*, unsigned int, void*, char const*)
(0x0846fb30) debug.cpp:316 debug_BuildErrorMessage(wchar_t const*, char const*, int, char const*, void*, char const*, ErrorMessageMem*)
(0x08470095) debug.cpp:437 debug_DisplayError(wchar_t const*, unsigned int, void*, char const*, char const*, int, char const*, unsigned char*)
(0x08470175) debug.cpp:515 debug_OnAssertionFailure(char const*, unsigned char*, char const*, int, char const*)
(0x0848b0ba) snd_mgr.cpp:127 al_ReportError
(0x0848b0ec) snd_mgr.cpp:141 al_check
(0x0848b400) snd_mgr.cpp:448 al_buf_free
(0x0848b431) snd_mgr.cpp:778 SndData_dtor
(0x0848078f) h_mgr.cpp:611 h_free_idx
(0x08480a00) h_mgr.cpp:761 h_force_free(long long, H_VTbl*)
(0x0848ac39) snd_mgr.cpp:934 hsd_list_free_all
(0x0848b355) snd_mgr.cpp:647 al_shutdown
(0x0848b378) snd_mgr.cpp:2025 snd_shutdown()
(0x0827f667) GameSetup.cpp:830 Shutdown(int)
(0x081db5d1) main.cpp:403 RunGameOrAtlas
(0x081db651) main.cpp:416 main

errno = 0 (?)
OS error = ?


(C)ontinue, (S)uppress, (B)reak, Launch (D)ebugger, or (E)xit?

According to http://opensource.creative.com/pipermail/o...ber/008854.html the Invalid Operation error can happen if a buffer is deleted while being attached to a source. So calling alSourcei() in al_shutdown() for every source fixes the problem for me:

Index: source/lib/res/sound/snd_mgr.cpp
===================================================================
--- source/lib/res/sound/snd_mgr.cpp (Revision 7003)
+++ source/lib/res/sound/snd_mgr.cpp (Arbeitskopie)
@@ -625,6 +625,14 @@
return;

// somewhat tricky: go through gyrations to free OpenAL resources.
+
+ // first remove source<->buffer associations
+ for (size_t i = 0; i < al_src_allocated; i++)
+ {
+ ALuint source = al_srcs[i];
+ debug_assert( alIsSource(source) );
+ alSourcei(source, AL_BUFFER, NULL);
+ }

// .. free all active sounds so that they release their source.
// the SndData reference is also removed,

Not sure if this is the correct fix, though. Also, sound in 0ad start screen is very crackling here anyway - might be a Pulseaudio problem.

This is on Ubuntu Jaunty, 32 bit, with some onboard Nvidia sound chip.

Link to comment
Share on other sites

From the end of this post:

hm, the docs say alDeleteBuffers can only fail with that error code if the buffer is still in use. However there is a mechanism in place for unqueuing buffers and stopping the source, which should happen before freeing buffers (even when shutting down). Unfortunately this problem doesn't occur on Windows (more forgiving OpenAL implementation?), so it's difficult to investigate. Would you be up to firing up the debugger and seeing what happens in vsrc_reclaim when shutting down?

If I start the game and then exit from the menu screen:

vsrc_reclaim is first called from:

#0  vsrc_reclaim (vs=0x971eb18) at ../../../source/lib/res/sound/snd_mgr.cpp:1613		  
#1 0x08495acf in VSrc_dtor (vs=0x971eb18) at ../../../source/lib/res/sound/snd_mgr.cpp:1207
#2 0x0848ad65 in h_free_idx (idx=62, hd=0x971eb00) at ../../../source/lib/res/h_mgr.cpp:609
#3 0x0848b06f in h_free (h=@0x987ea4c, type=0x859aac0) at ../../../source/lib/res/h_mgr.cpp:656
#4 0x08495090 in snd_free (hvs=@0x987ea4c) at ../../../source/lib/res/sound/snd_mgr.cpp:1322
#5 0x082e270f in JSI_Sound::Free (this=0x987ea00) at ../../../source/sound/JSI_Sound.cpp:164
#6 0x082e274e in ~JSI_Sound (this=0x987ea00) at ../../../source/sound/JSI_Sound.cpp:51
#7 0x082e3c2a in CJSObject<JSI_Sound, false>::DefaultFinalize (cx=0x8e69460, obj=0x986d388) at ../../../source/scripting/ScriptableObject.h:423
#8 0xb7a5fe42 in js_FinalizeObject () from /usr/lib/libjs.so
#9 0xb7a44ed5 in js_GC () from /usr/lib/libjs.so
#10 0xb7a2699c in js_DestroyContext () from /usr/lib/libjs.so
#11 0xb7a1ee22 in JS_DestroyContext () from /usr/lib/libjs.so
#12 0x082eebe8 in ~ScriptingHost (this=0x8e68370) at ../../../source/scripting/ScriptingHost.cpp:92
#13 0x08278527 in Shutdown (flags=0) at ../../../source/ps/GameSetup/GameSetup.cpp:805
#14 0x081dbe71 in RunGameOrAtlas (argc=1, argv=0xbfb7b894) at ../../../source/main.cpp:402
#15 0x081dbef1 in main (argc=1, argv=0xbfb7b894) at ../../../source/main.cpp:414

with *vs = {hvs = 270582941259, hsd = 274877908556, pos = {0, 0, 0}, gain = 1, pitch = 1, loop = 1 '\001', relative = 1 '\001', flags = 1, al_src = 160004984, static_pri = 0,

cur_pri = 0, fade = {start_time = 0, type = FT_NONE, length = 0, initial_val = 0, final_val = 0}}

It calls vsrc_deque_finished_bufs, which finds num_processed == 0 and so it doesn't do anything else.

vsrc_reclaim isn't called again. snd_shutdown is called, and al_buf_free fails.

This is with OpenAL Soft 1.7.411 on Gentoo, with ALSA.

Link to comment
Share on other sites

It calls vsrc_deque_finished_bufs, which finds num_processed == 0 and so it doesn't do anything else.

Ah, that explains it. Thanks for the debug info!

Line 1621 says "all queued buffers are now considered 'processed'", a claim that was apparently based on

removal of a given queue entry is not possible unless either the source is stopped (in which case the entire queue is considered processed) or [..]
from page 42 of the OpenAL 1.1 spec.

It seems this is not the case on both of your Linux implementations.

Your alSourcei suggestion is good - it is documented to clear out the entire queue and doesn't rely on all buffers allegedly going into the processed state. I'm not sure why I originally went with the vsrc_deque_finished_bufs approach.

It's probably better to do the cleanup in vsrc_reclaim and not just during shutdown, though - that way any leaks from game crashes are less likely/severe, and we avoid further contortions in al_shutdown.

I have committed a corresponding fix (#7029), but it works either way on Windows. Please let me know via PM if it still doesn't work (though I'll be on the road until Friday and won't have much time during the weekend).

Link to comment
Share on other sites

Guest olelukoie

Yes, it worked, but only once. I've done a simple test:

1. Run the game (pyrogenesys_dbg build 7037)

2. Entered single player mode

3. Pressed Esc and selected quit

4. Once again entered single-player mode.

The result is this:


$ ./pyrogenesis_dbg
TIMER| InitVfs: 810.446 us
TIMER| InitScripting: 2.92001 ms
TIMER| CONFIG_Init: 8.12626 ms
TIMER| write_sys_info: 1.6991 ms
TIMER| ps_console: 4.013 ms
TIMER| ps_lang_hotkeys: 5.69076 ms
TIMER| ps_gui_init: 32.334 us
TIMER| ps_gui_setup_xml: 3.36578 ms
TIMER| ps_gui_styles_xml: 2.10044 ms
TIMER| ps_gui_sprite1_xml: 119.33 ms
TIMER| ps_gui_1: 27.5693 ms
TIMER| ps_gui_2: 61.7445 ms
TIMER| ps_gui_3: 2.08696 ms
TIMER| ps_gui_4: 35.5307 ms
TIMER| ps_gui_6: 227.968 us
TIMER| ps_gui_6_1: 2.8483 ms
TIMER| ps_gui_6_2: 1.2511 ms
TIMER| ps_gui_7: 209.049 us
TIMER| ps_gui_9: 3.75367 ms
TIMER| InitRenderer: 19.6945 ms
TIMER| SimulationInit: 1.63349 ms
TIMER| Init_miscgamesection: 14.8612 ms
TIMER| Init_guiload: 50.8184 ms
socket(): Address family not supported by protocol
socket(): Address family not supported by protocol
ERROR: Failed to find matching prop point called "antler" in model "art/meshes/skeletal/deer_mesh.dae" for actor "fauna/deer.xml"
GAME STARTED, ALL INIT COMPLETE
ERROR: Failed to find matching prop point called "antler" in model "art/meshes/skeletal/deer_mesh.dae" for actor "fauna/deer.xml"
OpenAL error: Invalid Value; called from vsrc_deque_finished_bufs (#1)
snd_mgr.cpp(127): Assertion failed: "0"
udbg_bfd_init: loading symbols from ./pyrogenesis_dbg.
Assertion failed: "0"
Location: snd_mgr.cpp:127 (al_ReportError)

Call stack:

(0x008bba17) ldbg.cpp:101 debug_DumpStack(wchar_t*, unsigned long, void*, char const*)
(0x0087dc24) debug.cpp:316 debug_BuildErrorMessage(wchar_t const*, char const*, int, char const*, void*, char const*, ErrorMessageMem*)
(0x0087dff5) debug.cpp:437 debug_DisplayError(wchar_t const*, unsigned long, void*, char const*, char const*, int, char const*, unsigned char*)
(0x0087e2f6) debug.cpp:516 debug_OnAssertionFailure(char const*, unsigned char*, char const*, int, char const*)
(0x008a8de2) snd_mgr.cpp:127 al_ReportError
(0x008a8e19) snd_mgr.cpp:141 al_check
(0x008aad72) snd_mgr.cpp:1500 vsrc_deque_finished_bufs
(0x008aae19) snd_mgr.cpp:1537 vsrc_update
(0x008aaf1a) snd_mgr.cpp:1595 vsrc_grant
(0x008ab096) snd_mgr.cpp:1668 snd_play(long, float)
(0x006f391a) JSI_Sound.cpp:141 JSI_Sound::Play(JSContext*, unsigned int, long*)
(0x006f4990) ScriptableObject.h:185 CNativeFunction<JSI_Sound, false, bool, &(JSI_Sound::Play(JSContext*, unsigned int, long*))>::JSFunction(JSContext*, JSObject*, unsigned int, long*, long*)
(0x86b8e175) /usr/lib64/libjs.so.1:0 js_Invoke
(0x86b90158) /usr/lib64/libjs.so.1:0 js_Interpret
(0x86b8e788) /usr/lib64/libjs.so.1:0 js_Invoke
(0x86b8dc2f) /usr/lib64/libjs.so.1:0 js_InternalInvoke

errno = 0 (?)
OS error = ?


(C)ontinue, (S)uppress, (B)reak, Launch (D)ebugger, or (E)xit?

After pressing "C" the game started and immediatly crashed with segfault. Do you need gdb output?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...