microsoft / CLRInstrumentationEngine

The CLR Instrumentation Engine is a cooperation profiler that allows running multiple profiling extensions in the same process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logging causes issues on exiting on Ubuntu

jakubch1 opened this issue · comments

I was testing on ubuntu 18.04 our instrumentation method with latest CLR IE. We see issues when logging is enabled (when logging is disabled it works fine). For investiagation we disabled all our logic so our instrumentation method is just returning S_OK on all callbacks.

The scenario is that we have 3 dotnet processes.

  1. first process is starting second process and prints exit code of second process
  2. Second process is starting third process and prints exit code of third process
  3. Third process is just printing "Hello world"

When CLR IE is not attached or CLR IE is attached but logging is disabled all works fine and exit codes are correctly set to 0.

In case that CLR IE is enabled and logging is enabled (through env variable) we can see such exit codes:

  1. p1: 139, p2: 139, p3: 134
    OR
  2. p1: 139, p2:139, p3: hangs, after killing it we got 137
    OR
  3. p1: 139, p2:134, p3: hangs, after killing it we got 137'
    OR
  4. p1: 139, p2:134, p3: 134
    OR
  5. p1: 139, p2:134, p3: 139

If process is finishing with 134 we get such thing on output:
Fatal error: glibc detected an invalid stdio handle

Last messages in logs are:

LogMessage[14:54:25]:Ending ProfilerCallback AssemblyLoadFinished
LogMessage[14:54:25]:Starting ProfilerCallback Shutdown
LogMessage[14:54:25]:Sending event to Instrumentation Method
LogMessage[14:54:25]:Finished Sending event to Instrumentation Method. hr=0000

Sample full output:

jakubch@Jachocho-5820:~/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses$ dotnet test --settings dotnet.runsettings
  Determining projects to restore...
  All projects are up-to-date for restore.
  childprocesses -> /home/jakubch/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses/bin/Debug/net5.0/childprocesses.dll
Test run for /home/jakubch/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses/bin/Debug/net5.0/childprocesses.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 16.9.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Fatal error: glibc detected an invalid stdio handle
Fatal error: glibc detected an invalid stdio handle
[xUnit.net 00:00:05.17]     test.UnitTest1.Test [FAIL]
  Failed test.UnitTest1.Test [454 ms]
  Error Message:
   Exit code: 134, killed: False
output: MIDDLE Exit code: 134, killed: False
MIDDLE output: Hello World!

MIDDLE errors:

errors:
Expected: True
Actual:   False
  Stack Trace:
     at test.UnitTest1.Test() in /home/jakubch/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses/UnitTest1.cs:line 44
  Standard Output Messages:
 Exit code: 134, killed: False
 output: MIDDLE Exit code: 134, killed: False
 MIDDLE output: Hello World!

 MIDDLE errors:

 errors:



Attachments:
  /home/jakubch/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses/TestResults/725cc864-7799-480f-8459-d60297c49681/jakubch_Jachocho-5820_2021-03-17.14_59_56.coverage
Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: 454 ms - /home/jakubch/mstest/artifacts/test/8e3daa21-f12f-4424-95d6-b7cb2e9f353c/childprocesses/bin/Debug/net5.0/childprocesses.dll (net5.0)