# EventInstance::stop() crashes with callback

**URL:** <https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765>\
**Category:** FMOD Studio\
**Created:** [November 12, 2012, 2:00am UTC](https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765 "2012-11-12T02:00:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://qa.fmod.com/u/Kai)\
**Post date:** [November 12, 2012, 2:00am UTC](https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765/1 "2012-11-12T02:00:14Z")

</div>

If an EventInstance has a callback that uses EventInstance::release(), fmod will crash on a call to EventInstance::stop(FMOD\_STUDIO\_STOP\_IMMEDIATE).

Here is a simple callback from the examples that just calls EventInstance::release():

```auto
FMOD_RESULT F_CALLBACK eventCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, void* parameters)
{
    if (type == FMOD_STUDIO_EVENT_CALLBACK_STOPPED)
    {
        ERRCHECK( ((FMOD::Studio::EventInstance*)parameters)->release() );
    }

    return FMOD_OK;
}
```

Assuming I have an already created eventInstance, the following code will crash fmod:

```auto
ERRCHECK( eventInstance.setCallback(&eventCallback) );
ERRCHECK( eventInstance.stop(FMOD_STUDIO_STOP_IMMEDIATE) );
```

I am guessing this is because FMOD\_STUDIO\_STOP\_IMMEDIATE releases the event instance internally. Can anybody confirm this? Currently I am working around this by setting the callback to null before I use FMOD\_STUDIO\_STOP\_IMMEDIATE.

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://qa.fmod.com/u/Guest)\
**Post date:** [November 12, 2012, 8:18am UTC](https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765/2 "2012-11-12T08:18:03Z")

</div>

Thanks for the report. We have reproduced the crash here and will get this fixed as soon as possible.

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://qa.fmod.com/u/Guest)\
**Post date:** [November 19, 2012, 7:30am UTC](https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765/3 "2012-11-19T07:30:19Z")

</div>

This crash has now been fixed for the next release (version 0.01.04).

---

<div class="post-metadata">

**Author:** ![Kai](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kai](https://qa.fmod.com/u/Kai)\
**Post date:** [November 21, 2012, 11:15pm UTC](https://qa.fmod.com/t/eventinstance-stop-crashes-with-callback/10765/4 "2012-11-21T23:15:46Z")

</div>

Awesome, thanks!
