Skip to content

RUM-16390: Fall back to per-thread stack capture when getAllStackTraces fails - #4111

Draft
ambushwork wants to merge 1 commit into
developfrom
ylu/rum-16390-per-thread-stack-fallback-4f406c72
Draft

ambushwork wants to merge 1 commit into
developfrom
ylu/rum-16390-per-thread-stack-fallback-4f406c72

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

Makes thread stack capture tolerant of failures. A new shared helper, safeGetAllStackTraces, lives in dd-sdk-android-internal:

  • It calls Thread.getAllStackTraces() first.
  • If that throws, it enumerates live threads from the root ThreadGroup and reads each thread's stackTrace in its own try/catch. A thread that fails is skipped, and the failure goes to an onError callback, which callers log through InternalLogger (onlyOnce).
  • If both paths fail, it returns an empty map instead of throwing.

Two places now use it:

  • Profiling ThreadDumper: still drops the main thread and empty stacks.
  • RUM ANRDetectorRunnable: the ANR report now uses the stack snapshots it captured instead of reading the stacks a second time.

The new throwing calls are declared in detekt_custom_unsafe_calls.yml (kept sorted), and the internal module's API files are regenerated. No customer-facing API changes.

…es fails

Thread.getAllStackTraces() is all-or-nothing: one failing thread drops every stack. Add safeGetAllStackTraces in dd-sdk-android-internal, which falls back to enumerating the root ThreadGroup and reading each thread's stack separately, skipping threads that fail. Use it in the profiling ThreadDumper and the RUM ANRDetectorRunnable.
@ambushwork ambushwork changed the title Ylu/rum 16390 per thread stack fallback 4f406c72 RUM-16390: Fall back to per-thread stack capture when getAllStackTraces fails Nov 5, 2026
@ambushwork

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T16:44:32.878464Z a26e6ac Manual request
🔒 Security Review ✅ Completed 2026-11-05T16:45:35.226759Z a26e6ac Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a26e6ac21d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: a26e6ac21d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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.

1 participant