Skip to content
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

Read access violation - AudioEngine crash #18588

Open
m-peko opened this issue Dec 25, 2017 · 1 comment
Open

Read access violation - AudioEngine crash #18588

m-peko opened this issue Dec 25, 2017 · 1 comment

Comments

@m-peko
Copy link

m-peko commented Dec 25, 2017

  • cocos2d-x version: 3.16
  • devices test on: Windows 10
  • developing environments
    • VS version: 2015

Steps to Reproduce:

  1. Create new cpp project
  2. Play background music using AudioEngine play2d method
  3. Close application while running it in debugging mode

Exception thrown in CCScheduler.cpp:1047

void Scheduler::unschedule(SEL_SCHEDULE selector, Ref *target)
{
    // explicit handle nil arguments when removing an object
    if (target == nullptr || selector == nullptr)
    {
        return;
    }
    
    tHashTimerEntry *element = nullptr;

    HASH_FIND_PTR(_hashForTimers, &target, element); // Error line

    /* ... */
}

Call stack

libcocos2d.dll!cocos2d::Scheduler::unschedule(void(cocos2d::Ref::*)(float) selector, cocos2d::Ref * target) Line 1046	C++
libcocos2d.dll!cocos2d::experimental::AudioEngineImpl::~AudioEngineImpl() Line 127	C++
[External Code]	
libcocos2d.dll!cocos2d::experimental::AudioEngine::end() Line 160	C++
hello.exe!AppDelegate::~AppDelegate() Line 33	C++
hello.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 17	C++
[External Code]	
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	

Code for reproducing the error

bool AppDelegate::applicationDidFinishLaunching() {
    /* ... */

    auto scene = HelloWorld::createScene();

    AudioEngine::play2d("music.mp3", true);

    // run
    director->runWithScene(scene);

    return true;
}

Seems like the call to Scheduler::unschedule method from AudioEngineImpl destructor (AudioEngine-win32.cpp:124) is performed when the scheduler is already being deleted. Therefore the memory it is pointing to is invalid.

@drelaptop
Copy link
Contributor

@dumganhar will answer questions about AudioEngine days after, for he is quite busy recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants