Skip to content

Conversation

@bitsandfoxes
Copy link
Contributor

The Problem

The Sentry SDK for Unity receives stringified stack traces directly from Unity's logging system for error events (see getsentry/sentry-unity#2377). After parsing these stack traces, the Unity SDK sets them on the event as the current thread before passing the event to the .NET SDK for processing.

However, MainSentryEventProcessor is unconditionally adding a new "current thread" (with Current = true) whenever AttachStacktrace was enabled and no exception stack trace was present.

var thread = new SentryThread
{
Crashed = false,
Current = true,
Name = currentThread.Name,
Id = currentThread.ManagedThreadId,
Stacktrace = stackTrace
};

This resulted in events having two threads marked as current - the one from Unity with the correct stack trace, and a duplicate one captured by the .NET SDK.

Proposal

Just skip automatic current thread creation if the event already contains a thread with Current = true. This is not even related to the AttachStackTrace option as there only ever is one current thread anyway.

#skip-changelog

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (version6@8561566). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             version6    #4681   +/-   ##
===========================================
  Coverage            ?   73.18%           
===========================================
  Files               ?      480           
  Lines               ?    17421           
  Branches            ?     3437           
===========================================
  Hits                ?    12749           
  Misses              ?     3821           
  Partials            ?      851           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. I suggested one minor perf tweak...

Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
@bitsandfoxes bitsandfoxes merged commit ffeef7f into version6 Oct 31, 2025
47 of 48 checks passed
@bitsandfoxes bitsandfoxes deleted the fix/dont-overwrite-current-thread branch October 31, 2025 12:41
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

Successfully merging this pull request may close these issues.

3 participants