# Crash in Callback when Jumping to Another Marker in FMOD During a Transition

**URL:** <https://qa.fmod.com/t/crash-in-callback-when-jumping-to-another-marker-in-fmod-during-a-transition/22742>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [March 27, 2025, 10:30pm UTC](https://qa.fmod.com/t/crash-in-callback-when-jumping-to-another-marker-in-fmod-during-a-transition/22742 "2025-03-27T22:30:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reedysplash](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@reedysplash](https://qa.fmod.com/u/reedysplash)\
**Post date:** [March 27, 2025, 10:30pm UTC](https://qa.fmod.com/t/crash-in-callback-when-jumping-to-another-marker-in-fmod-during-a-transition/22742/1 "2025-03-27T22:30:22Z")

</div>

Hi,

We are experiencing a crash in Unity when trying to jump to another marker inside an FMOD event from a callback. Everything works fine until we reach the transition between two sections of the audio. At that moment, Unity crashes with an error.

Context  
We have an event in FMOD Studio with markers (Loop1, Transition, etc.).

In the FMOD callback, we try to detect a marker and jump to another marker within the same event.

The crash occurs exactly during the transition between audio sections.

Unity throws a SIGSEGV error and references FMOD.Studio.System:update()

At the moment we are using this callback:

```auto
protected override void StartGame()
    {
        base.StartGame();
        
        currentEvent.start();
        currentEvent.setCallback(EventCallback, EVENT_CALLBACK_TYPE.TIMELINE_MARKER);
    }

private RESULT EventCallback(EVENT_CALLBACK_TYPE type, IntPtr eventInstance, IntPtr parameters)
    {
        if (type == EVENT_CALLBACK_TYPE.TIMELINE_MARKER)
        {
            var properties = (TIMELINE_MARKER_PROPERTIES)Marshal.PtrToStructure(parameters, typeof(TIMELINE_MARKER_PROPERTIES));
            string nameString = properties.name;

            if (nameString.StartsWith("Loop"))
            {
                loopTimer = 0;
                indexArrow = 0;
                loopMusicPlaying = true;
                
                ++currentLoopsPlayedInLevel;
        
                currentEvent.setParameterByName(NextLevelParameter, 
                    (currentLoopsPlayedInLevel >= MaxLoopsPlayedPerLevel && currentLevel < NumLevels - 1) ? 1 : 0);
                
                if (currentLoopsPlayedInLevel == MaxLoopsPlayedPerLevel)
                {
                    currentEvent.setParameterByName(TransNextLevelParameter, currentLevel + 1);
                }
            }
            else if (nameString.StartsWith("Transition"))
            {
                if (currentLoopsPlayedInLevel >= MaxLoopsPlayedPerLevel && currentLevel < NumLevels - 1)
                {
                    currentLevel += 1;
                    currentLoopsPlayedInLevel = 0;
                }
                
                var indexLoopToPlay = new Random().Next(1, LoopsPerLevel);
                currentEvent.setParameterByName(LoopParameter, 1);
                currentEvent.setParameterByName(LevelParameter, currentLevel + 1); 
                currentLoopArrowsData = infiniteModeData[currentLevel].LoopsData[indexLoopToPlay].ArrowsData;
            }
        }
        return RESULT.OK;
    }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/039830077de3f5c92b93c6e470b28da809d19307.png)

The Unity crash log is the following:

```auto
=================================================================
	Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at FMOD.Studio.System:FMOD_Studio_System_Update <0x000e3>
	  at FMOD.Studio.System:update <0x0008a>
	  at FMODUnity.RuntimeManager:Update <0x02382>
	  at System.Object:runtime_invoke_void __this__ <0x00187>
=================================================================
Received signal SIGSEGV
Obtained 2 stack frames
RtlLookupFunctionEntry returned NULL function. Aborting stack walk.
<Missing stacktrace information>

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 31, 2025, 3:19am UTC](https://qa.fmod.com/t/crash-in-callback-when-jumping-to-another-marker-in-fmod-during-a-transition/22742/2 "2025-03-31T03:19:31Z")

</div>

Hi,

Thank you for the screenshots and the code.

The issue is you are missing the annotation: `[AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]` above the function and we need to make sure the callback function is `static`:

```auto
[AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]
static FMOD.RESULT BeatEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)

```

We have en example timeline marker callback script here: [Unity Integration | Scripting Examples - Timeline Callbacks](https://fmod.com/docs/2.02/unity/examples-timeline-callbacks.html).

Hope this helps!
