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

Prevent Segfault in EventPipe on disable #56104

Merged
merged 4 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/native/eventpipe/ep-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct _EventPipeProviderCallbackData {
#else
struct _EventPipeProviderCallbackData_Internal {
#endif
const ep_char8_t *filter_data;
ep_char8_t *filter_data;
EventPipeCallback callback_function;
void *callback_data;
int64_t keywords;
Expand Down
11 changes: 8 additions & 3 deletions src/native/eventpipe/ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ ep_provider_callback_data_alloc_copy (EventPipeProviderCallbackData *provider_ca
EventPipeProviderCallbackData *instance = ep_rt_object_alloc (EventPipeProviderCallbackData);
ep_raise_error_if_nok (instance != NULL);

if (provider_callback_data_src)
if (provider_callback_data_src) {
*instance = *provider_callback_data_src;
instance->filter_data = ep_rt_utf8_string_dup (provider_callback_data_src->filter_data);
}

ep_on_exit:
return instance;
Expand All @@ -270,7 +272,7 @@ ep_provider_callback_data_init (
{
EP_ASSERT (provider_callback_data != NULL);

provider_callback_data->filter_data = filter_data;
provider_callback_data->filter_data = ep_rt_utf8_string_dup (filter_data);
provider_callback_data->callback_function = callback_function;
provider_callback_data->callback_data = callback_data;
provider_callback_data->keywords = keywords;
Expand All @@ -289,19 +291,22 @@ ep_provider_callback_data_init_copy (
EP_ASSERT (provider_callback_data_src != NULL);

*provider_callback_data_dst = *provider_callback_data_src;
provider_callback_data_dst->filter_data = ep_rt_utf8_string_dup (provider_callback_data_src->filter_data);
return provider_callback_data_dst;
}

void
ep_provider_callback_data_fini (EventPipeProviderCallbackData *provider_callback_data)
{
;
ep_return_void_if_nok (provider_callback_data != NULL);
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_rt_utf8_string_free (provider_callback_data->filter_data);
}

void
ep_provider_callback_data_free (EventPipeProviderCallbackData *provider_callback_data)
{
ep_return_void_if_nok (provider_callback_data != NULL);
ep_provider_callback_data_fini (provider_callback_data);
ep_rt_object_free (provider_callback_data);
}

Expand Down