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 2 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-provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ provider_prepare_callback_data (

return ep_provider_callback_data_init (
provider_callback_data,
filter_data,
ep_rt_utf8_string_dup (filter_data),
josalem marked this conversation as resolved.
Show resolved Hide resolved
provider->callback_func,
provider->callback_data,
keywords,
Expand Down
8 changes: 4 additions & 4 deletions 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 All @@ -77,7 +77,7 @@ struct _EventPipeProviderCallbackData {
};
#endif

EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, const ep_char8_t *, filter_data)
josalem marked this conversation as resolved.
Show resolved Hide resolved
EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, ep_char8_t *, filter_data)
EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, EventPipeCallback, callback_function)
EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, void *, callback_data)
EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, int64_t, keywords)
Expand All @@ -86,7 +86,7 @@ EP_DEFINE_GETTER(EventPipeProviderCallbackData *, provider_callback_data, bool,

EventPipeProviderCallbackData *
ep_provider_callback_data_alloc (
const ep_char8_t *filter_data,
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_char8_t *filter_data,
EventPipeCallback callback_function,
void *callback_data,
int64_t keywords,
Expand All @@ -99,7 +99,7 @@ ep_provider_callback_data_alloc_copy (EventPipeProviderCallbackData *provider_ca
EventPipeProviderCallbackData *
ep_provider_callback_data_init (
EventPipeProviderCallbackData *provider_callback_data,
const ep_char8_t *filter_data,
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_char8_t *filter_data,
EventPipeCallback callback_function,
void *callback_data,
int64_t keywords,
Expand Down
12 changes: 8 additions & 4 deletions src/native/eventpipe/ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ep_provider_callback_data_queue_fini (EventPipeProviderCallbackDataQueue *provid

EventPipeProviderCallbackData *
ep_provider_callback_data_alloc (
const ep_char8_t *filter_data,
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_char8_t *filter_data,
EventPipeCallback callback_function,
void *callback_data,
int64_t keywords,
Expand All @@ -224,7 +224,7 @@ ep_provider_callback_data_alloc (

ep_raise_error_if_nok (ep_provider_callback_data_init (
instance,
filter_data,
ep_rt_utf8_string_dup (filter_data),
josalem marked this conversation as resolved.
Show resolved Hide resolved
callback_function,
callback_data,
keywords,
Expand All @@ -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 != NULL) {
josalem marked this conversation as resolved.
Show resolved Hide resolved
*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 @@ -261,7 +263,7 @@ ep_provider_callback_data_alloc_copy (EventPipeProviderCallbackData *provider_ca
EventPipeProviderCallbackData *
ep_provider_callback_data_init (
EventPipeProviderCallbackData *provider_callback_data,
const ep_char8_t *filter_data,
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_char8_t *filter_data,
EventPipeCallback callback_function,
void *callback_data,
int64_t keywords,
Expand Down Expand Up @@ -289,6 +291,7 @@ 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;
}

Expand All @@ -302,6 +305,7 @@ void
ep_provider_callback_data_free (EventPipeProviderCallbackData *provider_callback_data)
{
ep_return_void_if_nok (provider_callback_data != NULL);
ep_rt_utf8_string_free (provider_callback_data->filter_data);
josalem marked this conversation as resolved.
Show resolved Hide resolved
ep_rt_object_free (provider_callback_data);
}

Expand Down