Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make Crashpad Backend respect max_breadcrumbs setting #566

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,17 @@ sentry__crashpad_backend_shutdown(sentry_backend_t *backend)
}

static void
sentry__crashpad_backend_add_breadcrumb(
sentry_backend_t *backend, sentry_value_t breadcrumb)
sentry__crashpad_backend_add_breadcrumb(sentry_backend_t *backend,
sentry_value_t breadcrumb, const sentry_options_t *options)
{
crashpad_state_t *data = (crashpad_state_t *)backend->data;

bool first_breadcrumb = data->num_breadcrumbs % SENTRY_BREADCRUMBS_MAX == 0;
size_t max_breadcrumbs = options->max_breadcrumbs;

bool first_breadcrumb = data->num_breadcrumbs % max_breadcrumbs == 0;
Copy link
Member

Choose a reason for hiding this comment

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

To confirm: Can max_breadcrumbs ever be 0`?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. Code in other places was failing with max_breadcrumbs = 0, I fixed that up and its now correctly supported.


const sentry_path_t *breadcrumb_file
= data->num_breadcrumbs % (SENTRY_BREADCRUMBS_MAX * 2)
< SENTRY_BREADCRUMBS_MAX
= data->num_breadcrumbs % (max_breadcrumbs * 2) < max_breadcrumbs
? data->breadcrumb1_path
: data->breadcrumb2_path;
data->num_breadcrumbs++;
Expand Down
3 changes: 2 additions & 1 deletion src/sentry_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct sentry_backend_s {
sentry_backend_t *, const sentry_options_t *options);
// NOTE: The breadcrumb is not moved into the hook and does not need to be
// `decref`-d internally.
void (*add_breadcrumb_func)(sentry_backend_t *, sentry_value_t breadcrumb);
void (*add_breadcrumb_func)(sentry_backend_t *, sentry_value_t breadcrumb,
const sentry_options_t *options);
void (*user_consent_changed_func)(sentry_backend_t *);
uint64_t (*get_last_crash_func)(sentry_backend_t *);
void *data;
Expand Down
3 changes: 2 additions & 1 deletion src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ sentry_add_breadcrumb(sentry_value_t breadcrumb)
SENTRY_WITH_OPTIONS (options) {
if (options->backend && options->backend->add_breadcrumb_func) {
// the hook will *not* take ownership
options->backend->add_breadcrumb_func(options->backend, breadcrumb);
options->backend->add_breadcrumb_func(
options->backend, breadcrumb, options);
}
max_breadcrumbs = options->max_breadcrumbs;
}
Expand Down