diff --git a/CHANGELOG.md b/CHANGELOG.md index caa497b98..401e8d569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ **Fixes**: +- Reset client report counters during initialization ([#1632](https://github.com/getsentry/sentry-native/pull/1632)) - macOS: cache VM regions for FP validation in the new unwinder. ([#1634](https://github.com/getsentry/sentry-native/pull/1634)) ## 0.13.6 diff --git a/src/sentry_client_report.c b/src/sentry_client_report.c index f69bf7f90..2c553b9d8 100644 --- a/src/sentry_client_report.c +++ b/src/sentry_client_report.c @@ -64,3 +64,13 @@ sentry__client_report_restore(sentry_client_report_t *report) } memset(report, 0, sizeof(*report)); } + +void +sentry__client_report_reset(void) +{ + for (int r = 0; r < SENTRY_DISCARD_REASON_MAX; r++) { + for (int c = 0; c < SENTRY_DATA_CATEGORY_MAX; c++) { + sentry__atomic_store((long *)&g_discard_counts[r][c], 0); + } + } +} diff --git a/src/sentry_client_report.h b/src/sentry_client_report.h index 4f5e5b7de..d1e6372b5 100644 --- a/src/sentry_client_report.h +++ b/src/sentry_client_report.h @@ -63,4 +63,11 @@ bool sentry__client_report_save(sentry_client_report_t *report); */ void sentry__client_report_restore(sentry_client_report_t *report); +/** + * Reset all pending discard counters to zero. + * Called during sentry_init() so that stale counts from a previous session + * do not leak into the new one. + */ +void sentry__client_report_reset(void); + #endif diff --git a/src/sentry_core.c b/src/sentry_core.c index b3c214868..6ab61a810 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -172,6 +172,8 @@ sentry_init(sentry_options_t *options) sentry_close(); + sentry__client_report_reset(); + sentry_logger_t logger = { NULL, NULL, SENTRY_LEVEL_DEBUG }; if (options->debug) {