Skip to content
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
11 changes: 8 additions & 3 deletions src/coreclr/binder/bindertracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ bool BinderTracing::IsEnabled()

namespace BinderTracing
{
static thread_local bool t_AssemblyLoadStartInProgress = false;

AssemblyBindOperation::AssemblyBindOperation(AssemblySpec *assemblySpec, const WCHAR *assemblyPath)
: m_bindRequest { assemblySpec, nullptr, assemblyPath }
, m_populatedBindRequest { false }
Expand All @@ -209,6 +211,7 @@ namespace BinderTracing
if (!BinderTracing::IsEnabled() || ShouldIgnoreBind())
return;

t_AssemblyLoadStartInProgress = true;
PopulateBindRequest(m_bindRequest);
m_populatedBindRequest = true;
FireAssemblyLoadStart(m_bindRequest);
Expand All @@ -218,6 +221,8 @@ namespace BinderTracing
{
if (BinderTracing::IsEnabled() && !ShouldIgnoreBind())
{
t_AssemblyLoadStartInProgress = false;

// Make sure the bind request is populated. Tracing may have been enabled mid-bind.
if (!m_populatedBindRequest)
PopulateBindRequest(m_bindRequest);
Expand All @@ -244,9 +249,9 @@ namespace BinderTracing
if (m_checkedIgnoreBind)
return m_ignoreBind;

// ActivityTracker or EventSource may have triggered the system satellite load.
// Don't track system satellite binding to avoid potential infinite recursion.
m_ignoreBind = m_bindRequest.AssemblySpec->IsCoreLibSatellite();
// ActivityTracker or EventSource may have triggered the system satellite load, or load of System.Private.CoreLib
// Don't track such bindings to avoid potential infinite recursion.
m_ignoreBind = t_AssemblyLoadStartInProgress && (m_bindRequest.AssemblySpec->IsCoreLib() || m_bindRequest.AssemblySpec->IsCoreLibSatellite());
m_checkedIgnoreBind = true;
return m_ignoreBind;
}
Expand Down
27 changes: 25 additions & 2 deletions src/tests/tracing/eventpipe/complus_config/name_config_with_pid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ class NameConfigWithPid
{
static int Main(string[] args)
{
if (args.Length == 0)
Console.WriteLine("No Args");
else
Console.WriteLine($"args[0] = `{args[0]}`");

if (args.Length > 0 && args[0] == "waitforinput")
{
Console.Error.WriteLine("WaitingForInput in ErrorStream");
Console.WriteLine("WaitingForInput");
Console.Error.Flush();
Console.Out.Flush();
Console.ReadLine();
return 100;
}
Expand All @@ -31,7 +38,8 @@ static int Main(string[] args)
return 100;
}

string corerun = Path.Combine(Environment.GetEnvironmentVariable("CORE_ROOT"), "corerun");
string coreRoot = Environment.GetEnvironmentVariable("CORE_ROOT");
string corerun = Path.Combine(coreRoot, "corerun");
if (OperatingSystem.IsWindows())
corerun = corerun + ".exe";

Expand All @@ -49,15 +57,30 @@ static int Main(string[] args)
process.StartInfo.Environment.Add("COMPlus_EnableEventPipe", "1");
process.StartInfo.Environment.Add("COMPlus_EventPipeConfig", "Microsoft-Windows-DotNETRuntime:4c14fccbd:4");
process.StartInfo.Environment.Add("COMPlus_EventPipeOutputPath", outputPathPattern);
process.StartInfo.Environment.Add("CORE_ROOT", coreRoot);

Console.WriteLine($"Starting process '{process.StartInfo.FileName}' '{process.StartInfo.Arguments}'");
Console.Out.Flush();
process.Start();

process.StandardError.ReadLine();
string readFromTargetProcess = process.StandardError.ReadLine();
Console.WriteLine($"Readline '{readFromTargetProcess}'");
if (readFromTargetProcess != "WaitingForInput in ErrorStream")
{
Console.WriteLine($"Child process terminating");
Thread.Sleep(10000);
process.Kill();
Console.WriteLine($"Child process terminated");
}
Console.Out.Flush();
uint pid = (uint)process.Id;
string expectedPath = outputPathPattern.Replace("{pid}", pid.ToString());

process.StandardInput.WriteLine("input");
process.StandardInput.Flush();
process.WaitForExit();

Console.WriteLine($"StdErr ReadToEnd from child process '{process.StandardError.ReadToEnd()}'");
if (!File.Exists(expectedPath))
{
Console.WriteLine($"{expectedPath} not found");
Expand Down