{"action":"created","issue":{"url":"https://api.github.com/repos/LaurentGomila/SFML/issues/541","labels_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/541/labels{/name}","comments_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/541/comments","events_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/541/events","html_url":"https://github.com/LaurentGomila/SFML/issues/541","id":28568625,"number":541,"title":"Thread safety issues with sf::SoundStream and OpenAL","user":{"login":"Ceylo","id":451334,"avatar_url":"https://avatars.githubusercontent.com/u/451334?v=3","gravatar_id":"","url":"https://api.github.com/users/Ceylo","html_url":"https://github.com/Ceylo","followers_url":"https://api.github.com/users/Ceylo/followers","following_url":"https://api.github.com/users/Ceylo/following{/other_user}","gists_url":"https://api.github.com/users/Ceylo/gists{/gist_id}","starred_url":"https://api.github.com/users/Ceylo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ceylo/subscriptions","organizations_url":"https://api.github.com/users/Ceylo/orgs","repos_url":"https://api.github.com/users/Ceylo/repos","events_url":"https://api.github.com/users/Ceylo/events{/privacy}","received_events_url":"https://api.github.com/users/Ceylo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/bug","name":"bug","color":"ff4242"},{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/m:sfml-audio","name":"m:sfml-audio","color":"cccccc"},{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/p:osx","name":"p:osx","color":"888888"},{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/s:accepted","name":"s:accepted","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"mantognini","id":693483,"avatar_url":"https://avatars.githubusercontent.com/u/693483?v=3","gravatar_id":"","url":"https://api.github.com/users/mantognini","html_url":"https://github.com/mantognini","followers_url":"https://api.github.com/users/mantognini/followers","following_url":"https://api.github.com/users/mantognini/following{/other_user}","gists_url":"https://api.github.com/users/mantognini/gists{/gist_id}","starred_url":"https://api.github.com/users/mantognini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantognini/subscriptions","organizations_url":"https://api.github.com/users/mantognini/orgs","repos_url":"https://api.github.com/users/mantognini/repos","events_url":"https://api.github.com/users/mantognini/events{/privacy}","received_events_url":"https://api.github.com/users/mantognini/received_events","type":"User","site_admin":false},"milestone":null,"comments":20,"created_at":"2014-03-01T23:31:07Z","updated_at":"2015-03-13T23:03:29Z","closed_at":null,"body":"OpenAL does not look to be thread safe, at least on Mac OS X, thus loading and playing several SoundStreams at the same time produces crashes:\r\n```cpp\r\n#include <SFML/Audio.hpp>\r\nint main()\r\n{\r\n\tsf::Music m1, m2;\r\n\twhile (true) {\r\n\t\tm1.openFromFile(\"sound.wav\");\r\n\t\tm2.openFromFile(\"sound.wav\");\r\n\r\n\t\tm1.play();\r\n\t\tm2.play();\r\n\t\tm1.stop();\r\n\t\tm2.stop();\r\n\t}\r\n\treturn 0;\r\n}\r\n```\r\n\r\nproduced various crashes:\r\n```\r\nProcess:         a.out [54856]\r\nPath:            /Users/USER/Desktop/a.out\r\nIdentifier:      a.out\r\nVersion:         0\r\nCode Type:       X86-64 (Native)\r\nParent Process:  bash [54789]\r\nResponsible:     Terminal [33222]\r\nUser ID:         501\r\n\r\nDate/Time:       2014-03-02 00:26:49.738 +0100\r\nOS Version:      Mac OS X 10.9.2 (13C64)\r\nReport Version:  11\r\nAnonymous UUID:  9F6CC766-79FF-3090-9823-BD0B80A3AA2A\r\n\r\nSleep/Wake UUID: A2222B85-C3AB-431A-8355-49F316E8C6DE\r\n\r\nCrashed Thread:  5\r\n\r\nException Type:  EXC_BAD_ACCESS (SIGSEGV)\r\nException Codes: EXC_I386_GPFLT\r\n\r\nThread 0:: Dispatch queue: com.apple.main-thread\r\n0   libsystem_kernel.dylib        \t0x00007fff92afea3a __semwait_signal + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae47f3 pthread_join + 433\r\n2   org.sfml-dev.sfml-system      \t0x000000010d240d46 sf::Thread::wait() + 22\r\n3   a.out                         \t0x000000010d223d5a main + 490\r\n4   libdyld.dylib                 \t0x00007fff8997b5fd start + 1\r\n\r\nThread 1:: Dispatch queue: com.apple.libdispatch-manager\r\n0   libsystem_kernel.dylib        \t0x00007fff92aff662 kevent64 + 10\r\n1   libdispatch.dylib             \t0x00007fff96a6243d _dispatch_mgr_invoke + 239\r\n2   libdispatch.dylib             \t0x00007fff96a62152 _dispatch_mgr_thread + 52\r\n\r\nThread 2:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 3:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 4:: com.apple.audio.IOThread.client\r\n0   libsystem_kernel.dylib        \t0x00007fff92afaa1a mach_msg_trap + 10\r\n1   libsystem_kernel.dylib        \t0x00007fff92af9d18 mach_msg + 64\r\n2   com.apple.audio.CoreAudio     \t0x00007fff96aaf918 HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 98\r\n3   com.apple.audio.CoreAudio     \t0x00007fff96aaf8a6 HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 42\r\n4   com.apple.audio.CoreAudio     \t0x00007fff96aae02e HALC_ProxyIOContext::IOWorkLoop() + 950\r\n5   com.apple.audio.CoreAudio     \t0x00007fff96aadbcd HALC_ProxyIOContext::IOThreadEntry(void*) + 97\r\n6   com.apple.audio.CoreAudio     \t0x00007fff96aada8d HALB_IOThread::Entry(void*) + 75\r\n7   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n8   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n9   libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n\r\nThread 5 Crashed:\r\n0   com.apple.audio.OpenAL        \t0x000000010d26608d OALSource::RemoveBuffersFromQueue(unsigned int, unsigned int*) + 473\r\n1   com.apple.audio.OpenAL        \t0x000000010d25a77d alSourceUnqueueBuffers + 441\r\n2   org.sfml-dev.sfml-audio       \t0x000000010d22e620 sf::SoundStream::streamData() + 688\r\n3   org.sfml-dev.sfml-system      \t0x000000010d24159a sf::priv::ThreadImpl::entryPoint(void*) + 26\r\n4   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n5   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n6   libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n```\r\n\r\n\r\n```\r\nProcess:         a.out [54587]\r\nPath:            /Users/USER/Desktop/a.out\r\nIdentifier:      a.out\r\nVersion:         0\r\nCode Type:       X86-64 (Native)\r\nParent Process:  bash [54534]\r\nResponsible:     Terminal [33222]\r\nUser ID:         501\r\n\r\nDate/Time:       2014-03-01 23:56:25.515 +0100\r\nOS Version:      Mac OS X 10.9.2 (13C64)\r\nReport Version:  11\r\nAnonymous UUID:  9F6CC766-79FF-3090-9823-BD0B80A3AA2A\r\n\r\nSleep/Wake UUID: A2222B85-C3AB-431A-8355-49F316E8C6DE\r\n\r\nCrashed Thread:  5\r\n\r\nException Type:  EXC_CRASH (SIGABRT)\r\nException Codes: 0x0000000000000000, 0x0000000000000000\r\n\r\nApplication Specific Information:\r\nabort() called\r\n*** error for object 0x7fd6d8e1a0c0: double free\r\n \r\n\r\nThread 0:: Dispatch queue: com.apple.main-thread\r\n0   libsystem_kernel.dylib        \t0x00007fff92afea3a __semwait_signal + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae47f3 pthread_join + 433\r\n2   org.sfml-dev.sfml-system      \t0x0000000109719d46 sf::Thread::wait() + 22\r\n3   a.out                         \t0x00000001096fdd10 main + 480\r\n4   libdyld.dylib                 \t0x00007fff8997b5fd start + 1\r\n\r\nThread 1:: Dispatch queue: com.apple.libdispatch-manager\r\n0   libsystem_kernel.dylib        \t0x00007fff92aff662 kevent64 + 10\r\n1   libdispatch.dylib             \t0x00007fff96a6243d _dispatch_mgr_invoke + 239\r\n2   libdispatch.dylib             \t0x00007fff96a62152 _dispatch_mgr_thread + 52\r\n\r\nThread 2:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 3:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 4:: com.apple.audio.IOThread.client\r\n0   libsystem_kernel.dylib        \t0x00007fff92afaa1a mach_msg_trap + 10\r\n1   libsystem_kernel.dylib        \t0x00007fff92af9d18 mach_msg + 64\r\n2   com.apple.audio.CoreAudio     \t0x00007fff96aaf918 HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 98\r\n3   com.apple.audio.CoreAudio     \t0x00007fff96aaf8a6 HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 42\r\n4   com.apple.audio.CoreAudio     \t0x00007fff96aae02e HALC_ProxyIOContext::IOWorkLoop() + 950\r\n5   com.apple.audio.CoreAudio     \t0x00007fff96aadbcd HALC_ProxyIOContext::IOThreadEntry(void*) + 97\r\n6   com.apple.audio.CoreAudio     \t0x00007fff96aada8d HALB_IOThread::Entry(void*) + 75\r\n7   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n8   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n9   libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n\r\nThread 5 Crashed:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afe866 __pthread_kill + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae135c pthread_kill + 92\r\n2   libsystem_c.dylib             \t0x00007fff92f3cb1a abort + 125\r\n3   libsystem_malloc.dylib        \t0x00007fff894ab690 szone_error + 587\r\n4   com.apple.audio.units.Components\t0x000000010a427583 MixerSource::Initialize(AUMixer3D*) + 1759\r\n5   com.apple.audio.units.Components\t0x000000010a429dfb AUMixer3D::SetProperty(unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 261\r\n6   com.apple.audio.units.Components\t0x000000010a403ec6 AUBase::DispatchSetProperty(unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 1426\r\n7   com.apple.audio.units.Components\t0x000000010a492dda AUMethodSetProperty(void*, unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 127\r\n8   com.apple.audio.toolbox.AudioToolbox\t0x00007fff9505e526 _AT_AudioUnitSetProperty + 147\r\n9   com.apple.audio.OpenAL        \t0x000000010973a1e0 OALContext::GetAvailableStereoBus(unsigned int) + 298\r\n10  com.apple.audio.OpenAL        \t0x000000010974055b OALSource::SetupMixerBus() + 123\r\n11  com.apple.audio.OpenAL        \t0x000000010974107d OALSource::Play() + 329\r\n12  com.apple.audio.OpenAL        \t0x0000000109733fdc alSourcePlay + 29\r\n13  org.sfml-dev.sfml-audio       \t0x00000001097083df sf::SoundStream::streamData() + 111\r\n14  org.sfml-dev.sfml-system      \t0x000000010971a59a sf::priv::ThreadImpl::entryPoint(void*) + 26\r\n15  libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n16  libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n17  libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n```\r\n\r\n```\r\nProcess:         a.out [54575]\r\nPath:            /Users/USER/Desktop/a.out\r\nIdentifier:      a.out\r\nVersion:         0\r\nCode Type:       X86-64 (Native)\r\nParent Process:  bash [54534]\r\nResponsible:     Terminal [33222]\r\nUser ID:         501\r\n\r\nDate/Time:       2014-03-01 23:55:29.899 +0100\r\nOS Version:      Mac OS X 10.9.2 (13C64)\r\nReport Version:  11\r\nAnonymous UUID:  9F6CC766-79FF-3090-9823-BD0B80A3AA2A\r\n\r\nSleep/Wake UUID: A2222B85-C3AB-431A-8355-49F316E8C6DE\r\n\r\nCrashed Thread:  6\r\n\r\nException Type:  EXC_BAD_ACCESS (SIGSEGV)\r\nException Codes: KERN_INVALID_ADDRESS at 0x0000000000000000\r\n\r\nVM Regions Near 0:\r\n--> \r\n    __TEXT                 0000000101fbe000-0000000101fbf000 [    4K] r-x/rwx SM=COW  /Users/USER/Desktop/*.out\r\n\r\nThread 0:: Dispatch queue: com.apple.main-thread\r\n0   libsystem_kernel.dylib        \t0x00007fff92afea3a __semwait_signal + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae47f3 pthread_join + 433\r\n2   org.sfml-dev.sfml-system      \t0x0000000101fded46 sf::Thread::wait() + 22\r\n3   a.out                         \t0x0000000101fbecff main + 463\r\n4   libdyld.dylib                 \t0x00007fff8997b5fd start + 1\r\n\r\nThread 1:: Dispatch queue: com.apple.libdispatch-manager\r\n0   libsystem_kernel.dylib        \t0x00007fff92aff662 kevent64 + 10\r\n1   libdispatch.dylib             \t0x00007fff96a6243d _dispatch_mgr_invoke + 239\r\n2   libdispatch.dylib             \t0x00007fff96a62152 _dispatch_mgr_thread + 52\r\n\r\nThread 2:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 3:\r\n0   libsystem_kernel.dylib        \t0x00007fff92afee6a __workq_kernreturn + 10\r\n1   libsystem_pthread.dylib       \t0x00007fff8bae1f08 _pthread_wqthread + 330\r\n2   libsystem_pthread.dylib       \t0x00007fff8bae4fb9 start_wqthread + 13\r\n\r\nThread 4:: com.apple.audio.IOThread.client\r\n0   libsystem_kernel.dylib        \t0x00007fff92afaa1a mach_msg_trap + 10\r\n1   libsystem_kernel.dylib        \t0x00007fff92af9d18 mach_msg + 64\r\n2   com.apple.audio.CoreAudio     \t0x00007fff96aaf918 HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 98\r\n3   com.apple.audio.CoreAudio     \t0x00007fff96aaf8a6 HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 42\r\n4   com.apple.audio.CoreAudio     \t0x00007fff96aae02e HALC_ProxyIOContext::IOWorkLoop() + 950\r\n5   com.apple.audio.CoreAudio     \t0x00007fff96aadbcd HALC_ProxyIOContext::IOThreadEntry(void*) + 97\r\n6   com.apple.audio.CoreAudio     \t0x00007fff96aada8d HALB_IOThread::Entry(void*) + 75\r\n7   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n8   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n9   libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n\r\nThread 5:\r\n0   libsystem_kernel.dylib        \t0x00007fff92aff9f2 read + 10\r\n1   com.mega-nerd.sndfile         \t0x00000001020996b9 psf_fread + 202\r\n2   com.mega-nerd.sndfile         \t0x000000010209af67 float32_be_write + 1305\r\n3   com.mega-nerd.sndfile         \t0x00000001020613bb sf_read_short + 498\r\n4   org.sfml-dev.sfml-audio       \t0x0000000101fc4715 sf::Music::onGetData(sf::SoundStream::Chunk&) + 69\r\n5   org.sfml-dev.sfml-audio       \t0x0000000101fc9bc4 sf::SoundStream::fillAndPushBuffer(unsigned int) + 36\r\n6   org.sfml-dev.sfml-audio       \t0x0000000101fc93aa sf::SoundStream::streamData() + 58\r\n7   org.sfml-dev.sfml-system      \t0x0000000101fdf59a sf::priv::ThreadImpl::entryPoint(void*) + 26\r\n8   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n9   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n10  libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n\r\nThread 6 Crashed:\r\n0   com.apple.audio.OpenAL        \t0x0000000101fef975 alGenBuffers + 60\r\n1   org.sfml-dev.sfml-audio       \t0x0000000101fc9396 sf::SoundStream::streamData() + 38\r\n2   org.sfml-dev.sfml-system      \t0x0000000101fdf59a sf::priv::ThreadImpl::entryPoint(void*) + 26\r\n3   libsystem_pthread.dylib       \t0x00007fff8bae0899 _pthread_body + 138\r\n4   libsystem_pthread.dylib       \t0x00007fff8bae072a _pthread_start + 137\r\n5   libsystem_pthread.dylib       \t0x00007fff8bae4fc9 thread_start + 13\r\n```"},"comment":{"url":"https://api.github.com/repos/LaurentGomila/SFML/issues/comments/79517317","html_url":"https://github.com/LaurentGomila/SFML/issues/541#issuecomment-79517317","issue_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/541","id":79517317,"user":{"login":"mantognini","id":693483,"avatar_url":"https://avatars.githubusercontent.com/u/693483?v=3","gravatar_id":"","url":"https://api.github.com/users/mantognini","html_url":"https://github.com/mantognini","followers_url":"https://api.github.com/users/mantognini/followers","following_url":"https://api.github.com/users/mantognini/following{/other_user}","gists_url":"https://api.github.com/users/mantognini/gists{/gist_id}","starred_url":"https://api.github.com/users/mantognini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantognini/subscriptions","organizations_url":"https://api.github.com/users/mantognini/orgs","repos_url":"https://api.github.com/users/mantognini/repos","events_url":"https://api.github.com/users/mantognini/events{/privacy}","received_events_url":"https://api.github.com/users/mantognini/received_events","type":"User","site_admin":false},"created_at":"2015-03-13T23:03:29Z","updated_at":"2015-03-13T23:03:29Z","body":"Awesome!\r\n\r\n> Is the build script somewhere on the repo (ie. should it be updated?) or is it only a gist?\r\n\r\nNo, it's only a gist. I usually simply put the link to the gist in the related commit but that's it."}}