Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

brianrob
Copy link
Member

This change does two things:

  1. Ensure that EventPipe::CreateProvider doesn't SIGSEGV afterthe EventPipeConfiguration object has been destroyed during shutdown.
  2. Re-factor the code a bit so that providers are owned by an EventPipeConfiguration object. This will allow for multiple sessions in the future, and also removes the odd hack that required EventPipeProvider objects to lookup the singleton configuration object.

Fixes #13689.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, just few cosmetic nits.

}
CONTRACTL_END;

if(pProvider == NULL)
Copy link
Member

Choose a reason for hiding this comment

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

A nit - missing space between the "if" and the "(".

// Delete the provider now.
// NOTE: This will remove it from all of the EventPipe data structures.
delete(pProvider);
if(s_pConfig != NULL)
Copy link
Member

Choose a reason for hiding this comment

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

A nit - missing space between the "if" and the "(".


return new EventPipeProvider(providerName, pCallbackFunction, pCallbackData);
EventPipeProvider *pProvider = NULL;
if(s_pConfig != NULL)
Copy link
Member

Choose a reason for hiding this comment

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

A nit - missing space between the "if" and the "(".

@brianrob
Copy link
Member Author

Thanks @janvorli. Fixed.

@janvorli janvorli merged commit 42309c8 into dotnet:master Sep 22, 2017
Copy link

@nategraf nategraf left a comment

Choose a reason for hiding this comment

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

void Initialize();

// Create a new provider.
EventPipeProvider* CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction, void *pCallbackData);

Choose a reason for hiding this comment

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

Maybe change this signature to use default arguments of NULL for the callback functions to match the style of eventpipeprovider.h:67

Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually intentional - the reason is that for the most part, no one should call this version of CreateProvider because they should always go through EventPipe::CreateProvider.

@brianrob brianrob deleted the issue_13689 branch September 22, 2017 16:20
brianrob added a commit to brianrob/coreclr that referenced this pull request Nov 13, 2017
* Fix a crash that occurs when a provider is registered after the configuration object has been destroyed.

* Code review feedback.
nategraf pushed a commit to nategraf/coreclr that referenced this pull request Jan 6, 2018
* Fix a crash that occurs when a provider is registered after the configuration object has been destroyed.

* Code review feedback.
@joshgarnett
Copy link

Any chance this can be backported to the 2.0 runtime?

@brianrob
Copy link
Member Author

@joshgarnett yes, this will be ported to 2.0. You can watch #15444 for merge. Once the release branch is open, I will merge it.

@brianrob
Copy link
Member Author

Actually, I take it back, this is a different issue. Can you tell me more about how you're seeing this and how often it occurs?

@joshgarnett
Copy link

joshgarnett commented Jan 22, 2018

Hey @brianrob, I was seeing it consistently on an app I just upgraded from mono to dotnet. I think I narrowed the cause down to NLog. After adding an explicit call to LogManager.Shutdown() at the end of the main method, the problem went away. Without that change I confirmed it also didn't seg fault with the latest daily build.

(edit) The crash was in EventPipeConfiguration::RegisterProvider

@Imisnew2
Copy link

@brianrob @joshgarnett I believe the backport for this is being tracked in #15765. I've been eagerly waiting for it to make it into a servicing release :). As far as I can tell, the merge has been approved and simply has to be merged + released at this point.

@brianrob
Copy link
Member Author

Ok, thanks @joshgarnett.

@nategraf is #15765 approved or does this still need to go through shiproom?

#15444 is another related AV and it is approved and just needs to be merged (soon).

@nategraf
Copy link

It still needs to go through shiproom.

nategraf pushed a commit that referenced this pull request Jan 29, 2018
nategraf pushed a commit that referenced this pull request Jan 29, 2018
nategraf pushed a commit that referenced this pull request Jan 29, 2018
wtgodbe pushed a commit that referenced this pull request Feb 12, 2018
* Fix SIGSEGV in EventPipe on Shutdown (#14123)

* Fix a crash that occurs when a provider is registered after the configuration object has been destroyed.

* Code review feedback.

* Use DeleteProvider to avoid phantom registers providers
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants