erluk's picture

[Audio] Crash in AudioContext::CreateContext on x64

Project:The Open Toolkit library
Category:bug report

System: Vista 64bit
Soundcard: XFi Xtreme Music
Assembly target platform: both Any CPU and x64

When calling Alc.GetInteger on line 349 in AudioContext.cs, there is an unhandled StackOverflowException. This can be reproduced by running any of the OpenAL examples from the example browser.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


I am sorry, the file I attached is a x86 binary. I've attached the correct one to this post.

However, there seems to be something very wrong with this binary. The openal-info program crashes with an invalid context error (this is the program that comes with OpenAL Soft). OpenTK also fails to load this binary, for some unknown reason. Finally, I can confirm the StackOverflowException on Alc.GetInteger, when using Creative's installer - openal-info works correctly, so I suspect an issue in OpenTK, possibly some form of stack corruption (a real stack overflow is simply not possible here).

Things suddenly became more interesting...

the Fiddler's picture


Status:open» in progress

Indeed, we are corrupting the stack. Quoting from the specs:


6.3.8 Integer Query

void alcGetIntegerv(ALCdevice * deviceHandle, ALCenum token, ALCsizei size,ALCint *dest);

The application has to specifythe size of the destination buffer provided (in ALCint values).

We are specifying the buffer size in bytes (4 times larger than the correct).

However, the problem remains even after fixing this. Investigating.

the Fiddler's picture


Status:in progress» fixed

Issue fixed in rev. 1980.

Indeed, this was an instance of stack corruption. Alc.GetInteger didn't use the 'pin-buffer-and-pass-pointer' pattern used in the rest of OpenTK, causing issues when you called it like this:

int[] buffer = new buffer[...];
Alc.GetInteger(..., out buffer[0]);

This code works correctly now.

I have also added an array overload for convenience:

int[] buffer = new buffer[...];
Alc.GetInteger(..., buffer);
erluk's picture


I can confirm the fix, thanks for the quick response.

the Fiddler's picture


Status:fixed» closed

Closing bugs fixed in 0.9.8-2 and 0.9.9-1.

the Fiddler's picture


Version:0.9.x-dev» 0.9.9-1