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

System.Runtime.InteropServices.COMException (0x800700EA): More data is available. (Exception from HRESULT: 0x800700EA) #1767

Open
jiahuizheng1114 opened this issue Dec 12, 2022 · 3 comments
Labels

Comments

@jiahuizheng1114
Copy link

System.Runtime.InteropServices.COMException (0x800700EA): More data is available. (Exception from HRESULT: 0x800700EA)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.GetActiveSessionNames()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.Utility.TraceEventUtil.CreateSession(String sessionName)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServiceWorker.Initialize()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.<>c__DisplayClass21_1.b__0()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.HandleException(String callerName, Action body)

@brianrob
Copy link
Member

brianrob commented Jan 4, 2023

Can you please put together a set of steps/repro code that causes this?

@ryandle
Copy link
Member

ryandle commented May 9, 2023

Hey @brianrob, hope you are well. I just hit this during some local testing. Repro information:

  • Windows 11 build 22621.1555
  • I have 65 ETW sessions active on the machine

What seems to happen is:

  1. TraceEventSession.GetActiveSessionNames() gets MAX_SESSIONS from GetETWMaxLoggers() introduced in Read Max ETW Loggers from Registry Key #1408
  2. GetETWMaxLoggers is checking SYSTEM\\CurrentControlSet\\Control\\WMI EtwMaxLoggers key, but that doesn't seem to exist in my registry, so it defaults to 64
  3. GetActiveSessionNames calls QueryAllTraces and gets ERROR_MORE_DATA
  4. It then throws on the next line with the call to ThrowExceptionForHR

So, a few ideas on how to fix:

  1. The code seems to assume that EtwMaxLoggers is set in the registry if the system supports more than 64 loggers, but that doesn't seem to be the case on my windows 11 machine. Perhaps there is another way to check for current supported max loggers?
  2. An alternative would be to check for the ERROR_MORE_DATA return code and call QueryAllTraces again with the new max session count value it has set in the ref sessionCount parameter.

Any other ideas?

Happy to submit a PR if you think one of these is viable. I lean towards option 2 as I couldn't find a lot of good documentation on the EtwMaxLoggers registry setting.

@brianrob
Copy link
Member

brianrob commented May 9, 2023

@ryandle, thanks for the analysis. I agree that the second fix sounds right to me. Would be happy to accept a PR on this.

64 is the default value, though Windows 10+ does allow for larger values - https://learn.microsoft.com/en-us/windows/win32/api/evntrace/nf-evntrace-queryalltracesa#parameters.

ryandle pushed a commit to ryandle/perfview that referenced this issue May 10, 2023
This change updates GetActiveSessionNames to check for ERROR_MORE_DATA and retry once when calling QueryAllTraces.

I chose to implement this by modifying the current function as little as possible. To do that, I wrapped the core logic and made a recursive call to it for the retry, with a depth counter that maxes out at 1.

This change also has a unit test, but I don't think it is ready to be comitted. I am including it so a discussion can be had. In general it seems hard to reliably simulate this condition on a broad set of machines that will run this test suite (65+ active etw sessions while EtwMaxLoggers registry key is not set.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants