New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation error in the destructor of sf::AudioDevice #30

Closed
fpoisson opened this Issue Apr 22, 2011 · 60 comments

Comments

Projects
None yet
@fpoisson

fpoisson commented Apr 22, 2011

Access Violation error occurs int the destructor of sf::AudioDevice on Windows XP SP3. It doesn't occur on Windows 7 and Windows Vista.

Here is the instruction pointed by the visual C++ 2008 debugger:

Code:

AudioDevice::~AudioDevice() 
{ 
    // Destroy the context 
    alcMakeContextCurrent(NULL); 
    if (audioContext) 
=>           alcDestroyContext(audioContext); 

    // Destroy the device 
    if (audioDevice) 
        alcCloseDevice(audioDevice); 
} 

The error can be reproduced with this simple code :

#include <SFML/Audio.hpp> 

int main() 
{ 
    sf::Sound Sound; 

    return EXIT_SUCCESS; 
} 

This problem was first discussed in this post of the french forum :
http://www.sfml-dev.org/forum-fr/viewtopic.php?t=3443

@ghost ghost assigned LaurentGomila Apr 22, 2011

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Apr 22, 2011

Member

Which version of SFML? Which libraries (dynamic or static)? Are you sure that you use the openal32.dll file provided in the extlibs/bin directory?

Member

LaurentGomila commented Apr 22, 2011

Which version of SFML? Which libraries (dynamic or static)? Are you sure that you use the openal32.dll file provided in the extlibs/bin directory?

@fpoisson

This comment has been minimized.

Show comment
Hide comment
@fpoisson

fpoisson Apr 23, 2011

I use the dll versions of this SFML2's revision :

  • Revision: ad79328
  • Date: 15/04/2011 18:14:35
  • Message: Fixed recursive mutex lock in GlContext::Cleanup()

I use the openal32.dll file provided in the extlibs/bin/x86/ directory.

fpoisson commented Apr 23, 2011

I use the dll versions of this SFML2's revision :

  • Revision: ad79328
  • Date: 15/04/2011 18:14:35
  • Message: Fixed recursive mutex lock in GlContext::Cleanup()

I use the openal32.dll file provided in the extlibs/bin/x86/ directory.

@fpoisson

This comment has been minimized.

Show comment
Hide comment
@fpoisson

fpoisson Apr 23, 2011

With the statics versions (debug & release), the error doesn't occur.

fpoisson commented Apr 23, 2011

With the statics versions (debug & release), the error doesn't occur.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Apr 23, 2011

Member

Ok, I know what's wrong. Thanks for your feedback.

Member

LaurentGomila commented Apr 23, 2011

Ok, I know what's wrong. Thanks for your feedback.

@kevvo1288

This comment has been minimized.

Show comment
Hide comment
@kevvo1288

kevvo1288 May 2, 2011

I am having the same problem in Windows 7.
Steps:

  1. Generate project using Cmake
  2. Build all Projects in Visual Studio 2010 (32 bit, assume from now on)
  3. Try to run pong - Can't find SFML dlls.
  4. Add SFML debug dlls to directory.
  5. Try to run pong - Can't find openAL32.dll
  6. Add openAl and libsnd dlls to directory.
  7. Try to run pong - crashes on alcDestroyContext(audioContext); (in AudioDevice::~AudioDevice() )
  8. Add resources directory (I am slow but thorough :) )
  9. Try to run pong - IT WORKS!!! Game plays just fine, sound happens, etc...
  10. Press escape to quit pong - crashes on alcCloseDevice(audioDevice); (in AudioDevice::~AudioDevice() )

Same issue: It crashes in the deconstructor, although the exact line it fails on depends on whether or not the context has been created.

I'm free to experiment if there is a fix you'd like to try. I have the SFML git repo separate from the output from Cmake.

kevvo1288 commented May 2, 2011

I am having the same problem in Windows 7.
Steps:

  1. Generate project using Cmake
  2. Build all Projects in Visual Studio 2010 (32 bit, assume from now on)
  3. Try to run pong - Can't find SFML dlls.
  4. Add SFML debug dlls to directory.
  5. Try to run pong - Can't find openAL32.dll
  6. Add openAl and libsnd dlls to directory.
  7. Try to run pong - crashes on alcDestroyContext(audioContext); (in AudioDevice::~AudioDevice() )
  8. Add resources directory (I am slow but thorough :) )
  9. Try to run pong - IT WORKS!!! Game plays just fine, sound happens, etc...
  10. Press escape to quit pong - crashes on alcCloseDevice(audioDevice); (in AudioDevice::~AudioDevice() )

Same issue: It crashes in the deconstructor, although the exact line it fails on depends on whether or not the context has been created.

I'm free to experiment if there is a fix you'd like to try. I have the SFML git repo separate from the output from Cmake.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila May 2, 2011

Member

Thanks for your feedback. Like I said previously, I know what's wrong and I'll fix it soon.

Member

LaurentGomila commented May 2, 2011

Thanks for your feedback. Like I said previously, I know what's wrong and I'll fix it soon.

@dvoid

This comment has been minimized.

Show comment
Hide comment
@dvoid

dvoid Jun 13, 2011

been quiet here for a while, Any news about this bug? i really really need a fix as soon as possible. tanks

dvoid commented Jun 13, 2011

been quiet here for a while, Any news about this bug? i really really need a fix as soon as possible. tanks

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Jun 13, 2011

Member

As you can see, it's planned for SFML 2.x, not 2.0. So it's not the top priority, sorry.

Member

LaurentGomila commented Jun 13, 2011

As you can see, it's planned for SFML 2.x, not 2.0. So it's not the top priority, sorry.

@gchatelet

This comment has been minimized.

Show comment
Hide comment
@gchatelet

gchatelet Nov 28, 2011

Laurent can you explain a bit more on "Ok, I know what's wrong", so we can have a look and maybe submit a patch at some point ? I'm also running into this issue.

gchatelet commented Nov 28, 2011

Laurent can you explain a bit more on "Ok, I know what's wrong", so we can have a look and maybe submit a patch at some point ? I'm also running into this issue.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Nov 28, 2011

Member

Yeah, it's simple: the AudioDevice instance is destroyed at global exit.

Member

LaurentGomila commented Nov 28, 2011

Yeah, it's simple: the AudioDevice instance is destroyed at global exit.

@yadurajiv

This comment has been minimized.

Show comment
Hide comment
@yadurajiv

yadurajiv Mar 14, 2012

If I don't use the openal32.dll that came with sfml2, this error does not seem to happen. The latest OpenAL32.dll loads up slow, but it does not crash on exit.

yadurajiv commented Mar 14, 2012

If I don't use the openal32.dll that came with sfml2, this error does not seem to happen. The latest OpenAL32.dll loads up slow, but it does not crash on exit.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Mar 14, 2012

Member

The latest OpenAL32.dll loads up slow, but it does not crash on exit.

The latest OpenAL32.dll from where?

Member

LaurentGomila commented Mar 14, 2012

The latest OpenAL32.dll loads up slow, but it does not crash on exit.

The latest OpenAL32.dll from where?

@yadurajiv

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Mar 14, 2012

Member

As far as I know, this version is not updated anymore.

Updated Summer 2009 : Version 2.0.7.0

Member

LaurentGomila commented Mar 14, 2012

As far as I know, this version is not updated anymore.

Updated Summer 2009 : Version 2.0.7.0

@yadurajiv

This comment has been minimized.

Show comment
Hide comment
@yadurajiv

yadurajiv Mar 14, 2012

hmm.. But strangely enough it works, for the time being. What codebase is the openal32 in the extlibs based on?

yadurajiv commented Mar 14, 2012

hmm.. But strangely enough it works, for the time being. What codebase is the openal32 in the extlibs based on?

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Mar 14, 2012

Member

The only implementation that is maintained and used everywhere now is OpenAL-Soft.

Member

LaurentGomila commented Mar 14, 2012

The only implementation that is maintained and used everywhere now is OpenAL-Soft.

@yadurajiv

This comment has been minimized.

Show comment
Hide comment
@yadurajiv

yadurajiv Mar 14, 2012

yup, the binaries here - http://kcat.strangesoft.net/openal.html gives the error, which means we are back at square one _ sighs

yadurajiv commented Mar 14, 2012

yup, the binaries here - http://kcat.strangesoft.net/openal.html gives the error, which means we are back at square one _ sighs

@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Apr 7, 2012

Contributor

I've got a similar crash on Windows 7 but on alcCloseDevice(audioDevice); in my project (different code). The sample code provided here to reproduce the bug correctly produces alcDestroyContext() bug though.

However the 1.14 DLL provided at http://kcat.strangesoft.net/openal.html#download fixes both my crash and the one quoted in this issue (NB: in the readme they say the provided OpenAL binary isn't redistributable).

Note that the 1.14 release is 9 days old.

Contributor

Ceylo commented Apr 7, 2012

I've got a similar crash on Windows 7 but on alcCloseDevice(audioDevice); in my project (different code). The sample code provided here to reproduce the bug correctly produces alcDestroyContext() bug though.

However the 1.14 DLL provided at http://kcat.strangesoft.net/openal.html#download fixes both my crash and the one quoted in this issue (NB: in the readme they say the provided OpenAL binary isn't redistributable).

Note that the 1.14 release is 9 days old.

@matpow2

This comment has been minimized.

Show comment
Hide comment
@matpow2

matpow2 Apr 12, 2012

Even with the 1.14 OpenAL-Soft DLL, I was getting crashes on Windows XP 32bit SP3. I managed to fix the issue by removing SFML's AudioDevice deconstructor. It seems like OpenAL-Soft uses an atexit deconstructor to clean up after itself, which is the case with SFML's AudioDevice deconstructor too. This probably leads to OpenAL/SFML trying to deinitialize stuff that's already been destroyed.

matpow2 commented Apr 12, 2012

Even with the 1.14 OpenAL-Soft DLL, I was getting crashes on Windows XP 32bit SP3. I managed to fix the issue by removing SFML's AudioDevice deconstructor. It seems like OpenAL-Soft uses an atexit deconstructor to clean up after itself, which is the case with SFML's AudioDevice deconstructor too. This probably leads to OpenAL/SFML trying to deinitialize stuff that's already been destroyed.

@GatorQue

This comment has been minimized.

Show comment
Hide comment
@GatorQue

GatorQue Jul 7, 2012

@matpow2
When I use 1.14 OpenAL-Soft DLL my crashes went away, perhaps you were picking up an older version somewhere else on your computer?

GatorQue commented Jul 7, 2012

@matpow2
When I use 1.14 OpenAL-Soft DLL my crashes went away, perhaps you were picking up an older version somewhere else on your computer?

@germinolegrand

This comment has been minimized.

Show comment
Hide comment
@germinolegrand

germinolegrand Apr 7, 2013

I have the same problem, with crashes very often. I can't wait any longer, any advice before i go and try to fix it myself ?

germinolegrand commented Apr 7, 2013

I have the same problem, with crashes very often. I can't wait any longer, any advice before i go and try to fix it myself ?

@germinolegrand

This comment has been minimized.

Show comment
Hide comment
@germinolegrand

germinolegrand Jun 29, 2013

The fix I did is actually a partial fix, there are no more crashes, but a lot of warnings in the console instead (not really a problem, but i don't like seeing warnings it means some errors might occur later). I will try to investigate later.

germinolegrand commented Jun 29, 2013

The fix I did is actually a partial fix, there are no more crashes, but a lot of warnings in the console instead (not really a problem, but i don't like seeing warnings it means some errors might occur later). I will try to investigate later.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Jun 30, 2013

Member

Until you fix your fix (the diff shows all the files being completely changed -- probably due to different line breaks), there's no way to know what you did...

Member

LaurentGomila commented Jun 30, 2013

Until you fix your fix (the diff shows all the files being completely changed -- probably due to different line breaks), there's no way to know what you did...

@Oberon00

This comment has been minimized.

Show comment
Hide comment
@Oberon00

Oberon00 Jun 30, 2013

Contributor

You can append &w=1 to the commit URL to see only non-whitespace changes.

Contributor

Oberon00 commented Jun 30, 2013

You can append &w=1 to the commit URL to see only non-whitespace changes.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Jun 30, 2013

Member

Rather ?w=1 since the commit URL has no other argument ;)

So according to what I see, you moved the AudioDevice class from private to public. How does that solve anything?

Member

LaurentGomila commented Jun 30, 2013

Rather ?w=1 since the commit URL has no other argument ;)

So according to what I see, you moved the AudioDevice class from private to public. How does that solve anything?

@manolismi

This comment has been minimized.

Show comment
Hide comment
@manolismi

manolismi Jun 23, 2014

For me it didn't! This bug needs to be fixed soon, because every application that uses audio crashes! Hell, you can't distribute applications that crash! Because of mine application being fullscreen, when you click a button i made for closing the application, it freezes! The segmation error window pops behind the game and is not shown! And unless you click ok on it, the application can't close! But you can't click it because you don't see it! So reboot is the only option!

manolismi commented Jun 23, 2014

For me it didn't! This bug needs to be fixed soon, because every application that uses audio crashes! Hell, you can't distribute applications that crash! Because of mine application being fullscreen, when you click a button i made for closing the application, it freezes! The segmation error window pops behind the game and is not shown! And unless you click ok on it, the application can't close! But you can't click it because you don't see it! So reboot is the only option!

@manolismi

This comment has been minimized.

Show comment
Hide comment
@manolismi

manolismi Jun 23, 2014

Anyways, is there something that I can do that fixes it? If yes, please explain. Thank you very much, SFML is great and it is a pity that this bug is harassing my first game experience.

manolismi commented Jun 23, 2014

Anyways, is there something that I can do that fixes it? If yes, please explain. Thank you very much, SFML is great and it is a pity that this bug is harassing my first game experience.

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Jun 23, 2014

Member

Use this experimental branch and see if it fixes the problem (it should). It might get merged at some point, but don't hold your breath.

Member

binary1248 commented Jun 23, 2014

Use this experimental branch and see if it fixes the problem (it should). It might get merged at some point, but don't hold your breath.

@manolismi

This comment has been minimized.

Show comment
Hide comment
@manolismi

manolismi Jun 23, 2014

Thanks for replying, can you explain to me though what exactly I need to do? Replace the files by the corresponding experimentals?

manolismi commented Jun 23, 2014

Thanks for replying, can you explain to me though what exactly I need to do? Replace the files by the corresponding experimentals?

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Jun 23, 2014

Member

Just download the zip and pretend you got it instead of the original SFML files. Of course you will have to build it yourself since there are no pre-compiled versions of branches.

Member

binary1248 commented Jun 23, 2014

Just download the zip and pretend you got it instead of the original SFML files. Of course you will have to build it yourself since there are no pre-compiled versions of branches.

@manolismi

This comment has been minimized.

Show comment
Hide comment
@manolismi

manolismi Jun 23, 2014

I don't know how to build it! I read the tutorial building with cmake but I can't do it. I have mingw and dev c++ 5.6.3 IDE

manolismi commented Jun 23, 2014

I don't know how to build it! I read the tutorial building with cmake but I can't do it. I have mingw and dev c++ 5.6.3 IDE

@PatrickTorgerson

This comment has been minimized.

Show comment
Hide comment
@PatrickTorgerson

PatrickTorgerson Jun 23, 2014

hey manolismi, I have a working build for codeblocks and visual studio express 2013, both of wich dont have this problem if you want to switch to one ill send you one.

PatrickTorgerson commented Jun 23, 2014

hey manolismi, I have a working build for codeblocks and visual studio express 2013, both of wich dont have this problem if you want to switch to one ill send you one.

@achpile

This comment has been minimized.

Show comment
Hide comment
@achpile

achpile Jun 23, 2014

binary1248, Thanks a lot!!! This branch really fixes this annoying bug!!! Can't wait to see this branch merged into master! =)

achpile commented Jun 23, 2014

binary1248, Thanks a lot!!! This branch really fixes this annoying bug!!! Can't wait to see this branch merged into master! =)

@mantognini

This comment has been minimized.

Show comment
Hide comment
@mantognini

mantognini Jun 23, 2014

Member

@manolismi if you have a specific issue with cmake even after following 1:1 the tutorial and looking online for known solutions, you can ask for help on the forum (it's more appropriate there than here).

Member

mantognini commented Jun 23, 2014

@manolismi if you have a specific issue with cmake even after following 1:1 the tutorial and looking online for known solutions, you can ask for help on the forum (it's more appropriate there than here).

@manolismi

This comment has been minimized.

Show comment
Hide comment
@manolismi

manolismi Jun 24, 2014

Binary1248 I'm so grateful for your branch! Everything works! I can't thank you enough everyone, for your kindness and being helpful and supportive, even though I've spammed you a lot.

manolismi commented Jun 24, 2014

Binary1248 I'm so grateful for your branch! Everything works! I can't thank you enough everyone, for your kindness and being helpful and supportive, even though I've spammed you a lot.

binary1248 added a commit that referenced this issue Jul 4, 2014

Made OpenAL context management more intelligent, in analogy to OpenGL…
… context management. OpenAL contexts now only exist as long as AlResources require them and are destroyed when they are no longer required. Fixes #30.

@eXpl0it3r eXpl0it3r added the s:accepted label Jul 5, 2014

binary1248 added a commit that referenced this issue Jul 12, 2014

Made OpenAL context management more intelligent, in analogy to OpenGL…
… context management. OpenAL contexts now only exist as long as AlResources require them and are destroyed when they are no longer required. Fixes #30.

binary1248 added a commit that referenced this issue Aug 28, 2014

Made OpenAL context management more intelligent, in analogy to OpenGL…
… context management. OpenAL contexts now only exist as long as AlResources require them and are destroyed when they are no longer required. Fixes #30.
@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Sep 25, 2014

Contributor

As binary1248 seems to have fixed the issue, is it considered resolved?

Contributor

Ceylo commented Sep 25, 2014

As binary1248 seems to have fixed the issue, is it considered resolved?

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Sep 25, 2014

Member

It's in a branch that is not merged (tested) yet, so no. It will be marked as resolved after being merged into master.

Member

LaurentGomila commented Sep 25, 2014

It's in a branch that is not merged (tested) yet, so no. It will be marked as resolved after being merged into master.

@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Sep 25, 2014

Contributor

Ok. I couldn't find on which branch the commit was :)

Contributor

Ceylo commented Sep 25, 2014

Ok. I couldn't find on which branch the commit was :)

@binary1248

This comment has been minimized.

Show comment
Hide comment
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 11, 2014

How much time will this take to get merged in master?
Got the same problem and it's kind of annoying...

ghost commented Oct 11, 2014

How much time will this take to get merged in master?
Got the same problem and it's kind of annoying...

@Bromeon

This comment has been minimized.

Show comment
Hide comment
@Bromeon

Bromeon Oct 11, 2014

Member

As you see the milestone is 2.x, meaning it will happen after SFML 2.2.

But why don't you use the bugfix/al_context branch until then? The more feedback we get, the faster things will progress ;)

Member

Bromeon commented Oct 11, 2014

As you see the milestone is 2.x, meaning it will happen after SFML 2.2.

But why don't you use the bugfix/al_context branch until then? The more feedback we get, the faster things will progress ;)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 11, 2014

That's what i'm going to do, but I'm still learning a lot in C++ basics, and had some problems using Cmake last time ( almost an afternoon to get SFML2.1 ), so i'm kind of affraid of trying it again !
No choice I guess ;)

EDIT: Downloaded and linked new libraries compiled from: https://github.com/LaurentGomila/SFML/tree/bugfix/al_context
Still have the exact same problem...
Even with only "sf::Sound sound;" in the main function the error still appears.
Only fix I found is using static linking

Some help would be greatly appreciated :)

ghost commented Oct 11, 2014

That's what i'm going to do, but I'm still learning a lot in C++ basics, and had some problems using Cmake last time ( almost an afternoon to get SFML2.1 ), so i'm kind of affraid of trying it again !
No choice I guess ;)

EDIT: Downloaded and linked new libraries compiled from: https://github.com/LaurentGomila/SFML/tree/bugfix/al_context
Still have the exact same problem...
Even with only "sf::Sound sound;" in the main function the error still appears.
Only fix I found is using static linking

Some help would be greatly appreciated :)

@eXpl0it3r eXpl0it3r removed this from the 2.x milestone Nov 13, 2014

@fpoisson fpoisson removed this from the 2.x milestone Nov 13, 2014

@binary1248 binary1248 closed this in 0ad401c Jan 1, 2015

@eXpl0it3r eXpl0it3r added this to the 2.3 milestone Jan 1, 2015

@zedfax

This comment has been minimized.

Show comment
Hide comment
@zedfax

zedfax Feb 13, 2016

I've just compiled SFML from master and same problem, my programm exit with value "-1 073 741 515")

zedfax commented Feb 13, 2016

I've just compiled SFML from master and same problem, my programm exit with value "-1 073 741 515")

@zsbzsb

This comment has been minimized.

Show comment
Hide comment
@zsbzsb

zsbzsb Feb 14, 2016

Member

@zedfax Please open a thread on the forum as I kinda doubt this is your issue.

Member

zsbzsb commented Feb 14, 2016

@zedfax Please open a thread on the forum as I kinda doubt this is your issue.

@mihaicirneala

This comment has been minimized.

Show comment
Hide comment
@mihaicirneala

mihaicirneala Jun 10, 2017

I still have the same problem on Windows 10, with dynamic linking and openal32.dll copied in the same dir with the executable..

mihaicirneala commented Jun 10, 2017

I still have the same problem on Windows 10, with dynamic linking and openal32.dll copied in the same dir with the executable..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment