microsoftgraph / microsoftgraph/microsoft-graph-comms-samples

Stack overflow (0xc00000fd) in RPCRT4.dll when using Bot Media SDK with .NET 9.0

Open
#851 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
253
Forks
275
Avg merge
1d 5h
Merged PRs (30d)
1

Description

Description

When using the Microsoft Bot Media SDK (Microsoft.Skype.Bots.Media version 1.31.0.225-preview) with .NET 9.0, the application crashes with a stack overflow (STATUS_STACK_OVERFLOW / 0xc00000fd) in RPCRT4.dll shortly after successfully joining a Teams meeting.

Environment

  • OS: Windows Server 2022 Datacenter (Azure VM)
  • .NET Version: .NET 9.0
  • SDK Versions:
    • Microsoft.Skype.Bots.Media: 1.31.0.225-preview
    • Microsoft.Graph.Communications.Calls.Media: 1.2.0.15690
    • Microsoft.Graph.Communications.Client: 1.2.0.15690

Symptoms

  1. Bot successfully authenticates and joins the Teams meeting
  2. Media session is established (call state transitions to Established)
  3. ~5-10 seconds after joining, the process crashes with:
    • Exception Code: 0xc00000fd (STATUS_STACK_OVERFLOW)
    • Faulting Module: RPCRT4.dll
    • Faulting Application: VoiceRail.Voice.exe

Investigation Findings

We extensively tested various hypotheses:

  1. Disabled ALL event handlers (AudioMediaReceived, AudioSendStatusChanged, Participants.OnUpdated) - still crashed
  2. Offloaded event handlers to ThreadPool - still crashed
  3. Deferred event subscription from constructor - still crashed
  4. Tested SDK version 1.31.0.225-preview (minimum required by Calls.Media) - still crashed

The crash occurs INSIDE the SDK's native code, not in our managed code.

Root Cause

After extensive research, we identified this as a .NET 9.0 Control Flow Guard (CFG) compatibility issue:

  • .NET 9.0 introduced stricter CFG/CET (Control-flow Enforcement Technology) enforcement
  • The Bot Media SDK's native DLLs make RPC callbacks into managed code
  • These callbacks fail CFG stack validation, causing the stack overflow in RPCRT4.dll
  • Related issue: https://github.com/dotnet/runtime/issues/119067

Workaround

Adding <CETCompat>false</CETCompat> to the project file resolves the issue:

<PropertyGroup>
  <TargetFramework>net9.0</TargetFramework>
  <!-- Disable CET/CFG compatibility for Bot Media SDK native interop -->
  <CETCompat>false</CETCompat>
</PropertyGroup>

Request

  1. Documentation: Please document the .NET 9.0 compatibility issue and the CETCompat workaround
  2. SDK Update: Consider updating the Bot Media SDK to be compatible with .NET 9.0's CFG enforcement
  3. Official Support: Clarify if .NET 9.0 is officially supported or if .NET 8.0 LTS should be used

Reproduction Steps

  1. Create a new .NET 9.0 project targeting win-x64
  2. Add Microsoft.Skype.Bots.Media 1.31.0.225-preview
  3. Implement a basic Teams meeting bot following the samples
  4. Deploy to Windows Server 2022
  5. Join a Teams meeting
  6. Observe crash ~5-10 seconds after joining

Additional Context

  • The same code works correctly when <CETCompat>false</CETCompat> is added
  • We have not tested with .NET 8.0 (downgrade would also likely resolve the issue)
  • All Windows Media Foundation components and VC++ Redistributables are installed

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the six reproduction steps using .NET 9.0, Microsoft.Skype.Bots.Media 1.31.0.225-preview, and Windows Server 2022, then compare behavior with CETCompat set to false. Done means confirming the compatibility behavior and documenting the supported .NET version and workaround, or providing an SDK update that prevents the crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.