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 external profilers crashing when starting the server #5642

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MilonPL
Copy link
Contributor

@MilonPL MilonPL commented Jan 29, 2025

when launching through external profilers like ANTS or dotTrace in modes other than sampling/timeline, because of ???? we get an invalid handle error when trying to open files that don't exist, causing the entire program to crash

added a check for running under a profiler (yes i hate the nullable bool and scanning modules, but i dont know of a better way to do this) then we always check if the file exists in those cases

normal execution is still fast, we only eat the performance hit when running under these profilers (wont affect timeline though if you attach it later)

Copy link
Contributor

@FairlySadPanda FairlySadPanda left a comment

Choose a reason for hiding this comment

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

Definitely a PJB one this, just a quick suggestion on avoiding hardcoding

_isUnderProfiler ??= Process.GetCurrentProcess()
.Modules
.Cast<ProcessModule>()
.Any(m => m.ModuleName.Contains("JetBrains") ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't hardcode these.

@MilonPL
Copy link
Contributor Author

MilonPL commented Jan 29, 2025

I'm not sure if there's a better way to check for a profiler, and I can't hardcode in all of them. I guess maybe a custom command line argument? But also seems unnecessarily complex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants