fix: memory leaks, integer truncation, UB, and double-stop#26
Merged
Conversation
…ble-stop in cpu_profiler - Replace malloc with std::string in StartProfiling, StopProfiling, and GetFrameModuleWrapped to fix memory leaks on every call (RAII handles cleanup on all return paths) - Cast uint64_t to double before division in cpu_callback to preserve fractional precision in CPU usage stats - Stop and delete profiles inline in FreeAddonData then clear() the map, instead of calling CleanupSentryProfile which erases during iteration (undefined behavior on std::unordered_map) - Guard SentryProfile::Stop with a status check to make it idempotent, preventing double-stop when callers call Stop() before CleanupSentryProfile Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JonasBa
commented
Apr 30, 2026
| size_t len; | ||
| assert(napi_get_value_string_utf8(env, argv[0], NULL, 0, &len) == napi_ok); | ||
|
|
||
| char *abs_path = (char *)malloc(len + 1); |
Member
Author
There was a problem hiding this comment.
This was leaking the title
timfish
approved these changes
Apr 30, 2026
mydea
added a commit
to getsentry/sentry-javascript
that referenced
this pull request
May 8, 2026
…4.0 (#20720) Bumps this from 2.2.0 to 2.4.0, including the following changes: ## v2.4.0 * feat: Add Node 26 support (getsentry/sentry-javascript-profiling-node-binaries#32) ## v2.3.0 * fix: Memory leaks, integer truncation, UB, and double-stop (getsentry/sentry-javascript-profiling-node-binaries#26) * fix: Integer arithmetic for timestamps, emit elapsed_since_start_ns as string (getsentry/sentry-javascript-profiling-node-binaries#28) * fix: Dead member, capacity checks, insert perf, napi_env by value (getsentry/sentry-javascript-profiling-node-binaries#27) * chore: Replace execSync with execFileSync to prevent command injection (getsentry/sentry-javascript-profiling-node-binaries#23) * chore: Pin GitHub Actions to full-length commit SHAs (getsentry/sentry-javascript-profiling-node-binaries#24) * ci: Build Linux in container for wider glibc support (getsentry/sentry-javascript-profiling-node-binaries#16)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a couple bugs that claude found in the cpu profiler