Skip to content

[Crashlytics] Fix regex parsing issues#1488

Merged
a-maurice merged 7 commits into
mainfrom
am-stack_trace
Jul 15, 2026
Merged

[Crashlytics] Fix regex parsing issues#1488
a-maurice merged 7 commits into
mainfrom
am-stack_trace

Conversation

@a-maurice

@a-maurice a-maurice commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Description

Provide details of the change, and generalize the change in the PR title above.

Adjust the regex used to parse stack traces to be more precise, to avoid catastrophic backtracking issues caused by greedy matching.

Fixes #1484


Testing

Describe how you've tested these changes.

Testing examples with regex tools, to compare the results.
https://github.com/firebase/firebase-unity-sdk/actions/runs/29283437546


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Crashlytics stack trace parser to correctly handle stripped stack traces, specifically by refining regular expressions and handling file identifiers enclosed in angle brackets. It also refactors regex usage from Regex.Matches to Regex.IsMatch and Regex.Match for better efficiency. The review feedback suggests further performance optimizations by avoiding redundant regex evaluations between the matching and parsing steps, as well as simplifying a redundant string comparison condition.

Comment thread crashlytics/src/StackTraceParser.cs Outdated
Comment thread crashlytics/src/StackTraceParser.cs Outdated
@a-maurice

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors and improves the stack trace parsing logic in Crashlytics to support stripped stack traces, simplifying the matching flow and updating the regular expressions. The review feedback highlights two important improvements: replacing greedy wildcards in the file info regex to prevent potential catastrophic backtracking, and adding a defensive guard clause in ParseStackTraceString to avoid a NullReferenceException when the input stack trace is null or empty.

Comment thread crashlytics/src/StackTraceParser.cs Outdated
Comment thread crashlytics/src/StackTraceParser.cs
@a-maurice
a-maurice requested a review from AustinBenoit July 14, 2026 21:14
@a-maurice
a-maurice merged commit 1742482 into main Jul 15, 2026
13 checks passed
@a-maurice
a-maurice deleted the am-stack_trace branch July 15, 2026 20:29
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.

[Bug] Catastrophic backtracking in stacktrace regex with stripped symbols/limited stacktrace info

2 participants