Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Very simple sf::Music test crashes  (Read 10105 times)

0 Members and 1 Guest are viewing this topic.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Very simple sf::Music test crashes
« on: January 04, 2015, 09:00:22 pm »
On OS X 10.10, with both SFML 2.2 and Git head, running the following piece of code causes a Bus error:
int main()
{
        sf::Music music;

        if (! music.openFromFile("test.wav"))
                return 1;

        return 0;
}

The file "test.wav" does not exists, so failure is ok but it should not crash. LLDB backtrace is as follow:
Code: [Select]
* thread #1: tid = 0x1096d8, 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x100000f74)
  * frame #0: 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7
    frame #1: 0x00007fff8b70477d libsystem_pthread.dylib`pthread_mutex_destroy + 25
    frame #2: 0x000000010001a497 sfml-system`sf::Mutex::~Mutex() + 23
    frame #3: 0x0000000100006b31 sfml-audio`sf::Music::~Music() + 65
    frame #4: 0x0000000100000dfb a.out`main + 347
    frame #5: 0x00007fff8da4c5c9 libdyld.dylib`start + 1
    frame #6: 0x00007fff8da4c5c9 libdyld.dylib`start + 1
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Very simple sf::Music test crashes
« Reply #1 on: January 05, 2015, 01:03:32 am »
I guess does also happen on the no libsndfile branch but could you test it?
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #2 on: January 05, 2015, 10:07:53 pm »
I see 3 no libsndfile branches, which one is it? ;D
Want to play movies in your SFML application? Check out sfeMovie!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #4 on: January 05, 2015, 11:00:33 pm »
I get a crash a bit different:
Code: [Select]
* thread #1: tid = 0x17253e, 0x00007fff951b7caf libsystem_platform.dylib`_os_lock_corruption_abort, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007fff951b7caf libsystem_platform.dylib`_os_lock_corruption_abort
    frame #1: 0x00007fff951b686b libsystem_platform.dylib`_OSSpinLockLockSlow + 125
    frame #2: 0x00007fff8b70477d libsystem_pthread.dylib`pthread_mutex_destroy + 25
    frame #3: 0x000000010006b8c5 sfml-system`sf::priv::MutexImpl::~MutexImpl(this=0x00007fff5fbffa98) + 21 at MutexImpl.cpp:50
    frame #4: 0x000000010006b8e5 sfml-system`sf::priv::MutexImpl::~MutexImpl(this=0x00007fff5fbffa98) + 21 at MutexImpl.cpp:49
    frame #5: 0x000000010005c70d sfml-system`sf::Mutex::~Mutex(this=0x00007fff5fbffb58) + 45 at Mutex.cpp:49
    frame #6: 0x000000010005c765 sfml-system`sf::Mutex::~Mutex(this=0x00007fff5fbffb58) + 21 at Mutex.cpp:48
    frame #7: 0x000000010000ce69 sfml-audio`sf::Music::~Music(this=0x00007fff5fbffab0) + 57 at Music.cpp:51
    frame #8: 0x000000010000cf75 sfml-audio`sf::Music::~Music(this=0x00007fff5fbffab0) + 21 at Music.cpp:48
    frame #9: 0x0000000100000e35 a.out`main + 389
    frame #10: 0x00007fff8da4c5c9 libdyld.dylib`start + 1
    frame #11: 0x00007fff8da4c5c9 libdyld.dylib`start + 1

Dunno if the location change is relevant though.
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Very simple sf::Music test crashes
« Reply #5 on: January 06, 2015, 12:44:50 am »
I checked on 10.9, no problem to report.

Could you paste the stack of all threads?
SFML / OS X developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Very simple sf::Music test crashes
« Reply #6 on: January 06, 2015, 12:50:20 am »
Could you paste the stack of all threads?
In case you are using gdb and don't know how to do that, it's "thread apply all backtrace".
« Last Edit: January 06, 2015, 01:02:34 am by Jesper Juhl »

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #7 on: January 06, 2015, 09:12:16 am »
With master branch:
Code: [Select]
* thread #1: tid = 0x18bf98, 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x100001f18)
  * frame #0: 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7
    frame #1: 0x00007fff8b70477d libsystem_pthread.dylib`pthread_mutex_destroy + 25
    frame #2: 0x0000000100045e85 sfml-system`sf::priv::MutexImpl::~MutexImpl() + 21
    frame #3: 0x0000000100045e65 sfml-system`sf::priv::MutexImpl::~MutexImpl() + 21
    frame #4: 0x0000000100036ccd sfml-system`sf::Mutex::~Mutex() + 45
    frame #5: 0x0000000100036c95 sfml-system`sf::Mutex::~Mutex() + 21
    frame #6: 0x00000001000097cc sfml-audio`sf::Music::~Music() + 108
    frame #7: 0x0000000100009755 sfml-audio`sf::Music::~Music() + 21
    frame #8: 0x0000000100000e35 a.out`main + 389
    frame #9: 0x00007fff8da4c5c9 libdyld.dylib`start + 1
    frame #10: 0x00007fff8da4c5c9 libdyld.dylib`start + 1

  thread #2: tid = 0x18bfb9, 0x00007fff9185522e libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff9185522e libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff8d384d91 libdispatch.dylib`_dispatch_mgr_invoke + 247
    frame #2: 0x00007fff8d384a6a libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #3: tid = 0x18bfba, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #4: tid = 0x18bfbb, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #5: tid = 0x18bfbc, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #6: tid = 0x18bfbd, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #7: tid = 0x18bfcd, 0x00007fff9184f52e libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.audio.IOThread.client'
    frame #0: 0x00007fff9184f52e libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff9184e69f libsystem_kernel.dylib`mach_msg + 55
    frame #2: 0x00007fff97cb4980 CoreAudio`HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 98
    frame #3: 0x00007fff97cb490e CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 42
    frame #4: 0x00007fff97cb2f60 CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 952
    frame #5: 0x00007fff97cb2b0e CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 88
    frame #6: 0x00007fff97cb29eb CoreAudio`HALB_IOThread::Entry(void*) + 157
    frame #7: 0x00007fff8b7042fc libsystem_pthread.dylib`_pthread_body + 131
    frame #8: 0x00007fff8b704279 libsystem_pthread.dylib`_pthread_start + 176
    frame #9: 0x00007fff8b7024b1 libsystem_pthread.dylib`thread_start + 13

With no libsndfile branch:
Code: [Select]
* thread #1: tid = 0x18c937, 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x100001f18)
  * frame #0: 0x00007fff951b3fcf libsystem_platform.dylib`OSSpinLockLock + 7
    frame #1: 0x00007fff8b70477d libsystem_pthread.dylib`pthread_mutex_destroy + 25
    frame #2: 0x0000000100045e85 sfml-system`sf::priv::MutexImpl::~MutexImpl() + 21
    frame #3: 0x0000000100045e65 sfml-system`sf::priv::MutexImpl::~MutexImpl() + 21
    frame #4: 0x0000000100036ccd sfml-system`sf::Mutex::~Mutex() + 45
    frame #5: 0x0000000100036c95 sfml-system`sf::Mutex::~Mutex() + 21
    frame #6: 0x00000001000097cc sfml-audio`sf::Music::~Music() + 108
    frame #7: 0x0000000100009755 sfml-audio`sf::Music::~Music() + 21
    frame #8: 0x0000000100000e35 a.out`main + 389
    frame #9: 0x00007fff8da4c5c9 libdyld.dylib`start + 1
    frame #10: 0x00007fff8da4c5c9 libdyld.dylib`start + 1

  thread #2: tid = 0x18c954, 0x00007fff9185522e libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff9185522e libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff8d384d91 libdispatch.dylib`_dispatch_mgr_invoke + 247
    frame #2: 0x00007fff8d384a6a libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #3: tid = 0x18c955, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #4: tid = 0x18c956, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #5: tid = 0x18c957, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #6: tid = 0x18c958, 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff91854946 libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8b704757 libsystem_pthread.dylib`_pthread_wqthread + 869
    frame #2: 0x00007fff8b7024a1 libsystem_pthread.dylib`start_wqthread + 13

  thread #7: tid = 0x18c96b, 0x00007fff9184f52e libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.audio.IOThread.client'
    frame #0: 0x00007fff9184f52e libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff9184e69f libsystem_kernel.dylib`mach_msg + 55
    frame #2: 0x00007fff97cb3e11 CoreAudio`HALC_IOContext_Start + 135
    frame #3: 0x00007fff97cb2cad CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 261
    frame #4: 0x00007fff97cb2b0e CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 88
    frame #5: 0x00007fff97cb29eb CoreAudio`HALB_IOThread::Entry(void*) + 157
    frame #6: 0x00007fff8b7042fc libsystem_pthread.dylib`_pthread_body + 131
    frame #7: 0x00007fff8b704279 libsystem_pthread.dylib`_pthread_start + 176
    frame #8: 0x00007fff8b7024b1 libsystem_pthread.dylib`thread_start + 13
Want to play movies in your SFML application? Check out sfeMovie!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Very simple sf::Music test crashes
« Reply #8 on: January 06, 2015, 10:03:06 am »
Will the crash always happen if you have an sf::Music object or can you add some code and it doesn't happen anymore?
Do you get similar issues with sf::Sound?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Very simple sf::Music test crashes
« Reply #9 on: January 06, 2015, 10:53:51 am »
I couldn't find anything helpful in those other threads bt.. In three of them it crashes in OSSpinLockLock and one of them in _OSSpinLockLockSlow (which is not documented...). In all cases, it entered pthread_mutex_destroy which should return an error code on failure (EBUSY/EINVAL), not crash... And I couldn't find anything really similar on the Web.. :-\

Does it also happen with 2.1? (need to apply https://github.com/SFML/SFML/pull/699.patch or similar)
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #10 on: January 06, 2015, 08:40:53 pm »
Actually I was wondering why I was having the crash when compiling the sample manually, but not within Xcode. And I found out that any optimization level other than -O0 makes the crash disappear…
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #11 on: January 06, 2015, 08:50:19 pm »
I also noted that the "Current" link in the SFML audio framework links to version 2.1 of the binary, not 2.2, although I just installed SFML thought the "install" target.

Edit: fixing the symbolic link allowed the debugger to show the relevant line of code in SFML sources rather than assembly lines.

Edit 2: by the way, why does the install target installs both version 2.1 and 2.2 of the binaries? Actually it says it's already up-to-date but I don't understand why it even cares about the old version:
Code: [Select]
-- Installing: /Library/Frameworks/sfml-audio.framework
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Resources
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/sfml-audio
-- Installing: /Library/Frameworks/sfml-audio.framework/Versions
-- Installing: /Library/Frameworks/sfml-audio.framework/Versions/2.1.0
-- Installing: /Library/Frameworks/sfml-audio.framework/Versions/2.1.0/Resources
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Versions/2.1.0/Resources/Info.plist
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Versions/2.1.0/sfml-audio
-- Installing: /Library/Frameworks/sfml-audio.framework/Versions/2.2.0
-- Installing: /Library/Frameworks/sfml-audio.framework/Versions/2.2.0/Resources
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Versions/2.2.0/Resources/Info.plist
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Versions/2.2.0/sfml-audio
-- Up-to-date: /Library/Frameworks/sfml-audio.framework/Versions/Current

Edit 3: removing the old binaries from the SFML build directory allowed me to install only the relevant stuff with the correct binaries :)
« Last Edit: January 06, 2015, 09:00:19 pm by Ceylo »
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #12 on: January 06, 2015, 09:40:15 pm »
Ok I feel stupid now ;D the culprit was my old SFML headers in /usr/local/include, which were used instead of the ones in the SFML framework. Now it runs fine whatever I do ::)
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Very simple sf::Music test crashes
« Reply #13 on: January 06, 2015, 09:53:41 pm »
Glad you could find the source of error.  :D
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Very simple sf::Music test crashes
« Reply #14 on: January 06, 2015, 10:25:33 pm »
:D

Be careful though with the fact that it looks to be installing whatever binary it finds, even if it's old SFML ones, and especially the fact that the "Current" link does not target the freshly installed version.
Want to play movies in your SFML application? Check out sfeMovie!