Skip to content

fix(stacktrace): stop leaking internal frame state into event payload#2962

Merged
sl0thentr0py merged 1 commit into
masterfrom
fix/stacktrace-frame-payload-leak
Jun 1, 2026
Merged

fix(stacktrace): stop leaking internal frame state into event payload#2962
sl0thentr0py merged 1 commit into
masterfrom
fix/stacktrace-frame-payload-leak

Conversation

@sl0thentr0py
Copy link
Copy Markdown
Member

Summary

Interface#to_h serializes every instance variable, so helper ivars stored on StacktraceInterface::Frame leak into the event payload sent to Sentry. The FilenameCache change (#2904) made this worse: it serialized "#<Sentry::FilenameCache:0x...>" — a memory address that changes on every run — into every stack frame.

Version Junk leaked into every frame
6.5.0 project_root, strip_backtrace_load_path
HEAD (before this PR) strip_backtrace_load_path, filename_cache

This passes filename_cache/strip_backtrace_load_path through the constructor instead of storing them as ivars, so they never reach to_h. The now-unused private compute_filename helper is removed (the public FilenameCache#compute_filename is untouched). This also drops the pre-existing project_root/strip_backtrace_load_path leaks — none of these were part of Sentry's frame schema.

All real frame fields (abs_path, function, lineno, in_app, module, filename, *_context) are unchanged.

Verification

Replayed an identical fixed backtrace through Sentry.capture_exception on 6.5.0 and on this branch and diffed the serialized event: every meaningful frame field is byte-identical; only the leaked internal keys are gone. Added a regression spec asserting frame.to_h exposes only the real frame keys. Existing interface/backtrace/event/profiler specs pass; RuboCop clean.

🤖 Generated with Claude Code

Interface#to_h serializes every instance variable, so helper ivars
stored on StacktraceInterface::Frame leaked into the event payload. The
FilenameCache change (#2904) made this worse by serializing
"#<Sentry::FilenameCache:0x...>" — a memory address that differs on
every run — into every frame.

Pass filename_cache/strip_backtrace_load_path through the constructor
instead of storing them as ivars, so they never reach to_h. This also
drops the pre-existing project_root/strip_backtrace_load_path leaks. All
real frame fields are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sl0thentr0py sl0thentr0py merged commit af610cd into master Jun 1, 2026
286 of 287 checks passed
@sl0thentr0py sl0thentr0py deleted the fix/stacktrace-frame-payload-leak branch June 1, 2026 15:51
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.

2 participants