Hi, I have sample application with two threads - first one reads from stdin, second starts new child process, when old one is terminated.
It worked fine in netcoreapp2.2 both in windows and linux, netcoreapp3.0 preview7 at windows. However it doesn't work in preview7 at linux(RHEL7.6).
Thread 1
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: libpthread.so.0!__libc_read + 0x2d
Child-SP RetAddr Caller, Callee
00007FFC8D5A8B90 00007fca9131d6fd System.Native.so!SystemNative_ReadStdin + 0x1d, calling System.Native.so!read
00007FFC8D5A8BB0 00007fca214c3cbb (MethodDesc 00007fca21bca610 + 0x7b ILStubClass.IL_STUB_PInvoke(Byte*, Int32))
00007FFC8D5A8BF0 00007fca214c3cbb (MethodDesc 00007fca21bca610 + 0x7b ILStubClass.IL_STUB_PInvoke(Byte*, Int32))
00007FFC8D5A8C40 00007fca21703474 (MethodDesc 00007fca21bc94d0 + 0x124 System.IO.StdInReader.ReadKey(Boolean ByRef)), calling 00007fca216e1f28
00007FFC8D5A8C70 00007fca9a8eede7 libcoreclr.so!CodeVersionManager::PublishNativeCodeVersion(MethodDesc*, NativeCodeVersion, int) + 0x157, calling libcoreclr.so!CLRException::HandlerState::CleanupTry()
00007FFC8D5A8CE0 00007fca9a78ff38 libcoreclr.so!Precode::GetMethodDesc(int) + 0x48, calling libcoreclr.so!FixupPrecode::GetMethodDesc()
00007FFC8D5A8CF0 00007fca9aae15b7 libcoreclr.so!LeaveCriticalSection + 0x17, calling libcoreclr.so!pthread_getspecific
00007FFC8D5A8D10 00007fca9a7392e2 libcoreclr.so!CrstBase::Leave() + 0x12, calling libcoreclr.so!LeaveCriticalSection
00007FFC8D5A8D40 00007fca9a791232 libcoreclr.so!MethodDesc::DoBackpatch(MethodTable*, MethodTable*, int) + 0x982, calling libcoreclr.so!CrstBase::Leave()
00007FFC8D5A8DF0 00007fca9a793d6c libcoreclr.so!MethodDesc::DoPrestub(MethodTable*) + 0x28c, calling libcoreclr.so!MethodDesc::DoBackpatch(MethodTable*, MethodTable*, int)
00007FFC8D5A8E20 00007fca9aad1dbd libcoreclr.so!SetLastError + 0xd, calling libcoreclr.so!__errno_location
00007FFC8D5A8E40 00007fca9a794bea libcoreclr.so!ExternalMethodFixupWorker + 0xbaa, calling libcoreclr.so!SetLastError
00007FFC8D5A8E80 00007fca9aad1dbd libcoreclr.so!SetLastError + 0xd, calling libcoreclr.so!__errno_location
00007FFC8D5A8EA0 00007fca9a793912 libcoreclr.so!PreStubWorker + 0x272, calling libcoreclr.so!SetLastError
00007FFC8D5A8F50 00007fca9a8b660c libcoreclr.so!ThePreStub + 0x5c, calling libcoreclr.so!PreStubWorker
00007FFC8D5A8FE0 00007fca9131d2c0 System.Native.so!SystemNative_InitializeConsoleBeforeRead + 0x140, calling System.Native.so!pthread_mutex_unlock
00007FFC8D5A9040 00007fca2170343b (MethodDesc 00007fca21bc94d0 + 0xeb System.IO.StdInReader.ReadKey(Boolean ByRef)), calling libcoreclr.so!JIT_PInvokeEnd
00007FFC8D5A9088 00007fca21703419 (MethodDesc 00007fca21bc94d0 + 0xc9 System.IO.StdInReader.ReadKey(Boolean ByRef)), calling libcoreclr.so!JIT_PInvokeBegin
00007FFC8D5A9170 00007fca21702a47 (MethodDesc 00007fca21bc9438 + 0x87 System.IO.StdInReader.ReadLine(Boolean)), calling 00007fca216e1f28
00007FFC8D5A91B8 00007fca21702a13 (MethodDesc 00007fca21bc9438 + 0x53 System.IO.StdInReader.ReadLine(Boolean)), calling libcoreclr.so!JIT_PInvokeBegin
00007FFC8D5A9248 00007fca9a739400 libcoreclr.so!CrstBase::Enter() + 0xa0, calling libcoreclr.so!GetExecutionEngine()
00007FFC8D5A9280 00007fca217029b0 (MethodDesc 00007fca21bc9428 + 0x10 System.IO.StdInReader.ReadLine()), calling 00007fca216e1f28
00007FFC8D5A9290 00007fca21702153 (MethodDesc 00007fca21bc1408 + 0x43 System.IO.SyncTextReader.ReadLine()), calling 00007fca20b4b150
00007FFC8D5A92C0 00007fca216f85cd (MethodDesc 00007fca216658a8 + 0x1d System.Console.ReadLine()), calling 00007fca20b4b150
00007FFC8D5A92D0 00007fca214b1000 (MethodDesc 00007fca21561328 + 0xd0 Test.ChildTest.Main(System.String[])), calling 00007fca214b0e28 (stub for System.Console.ReadLine())
00007FFC8D5A9330 00007fca9a8b595f libcoreclr.so!CallDescrWorkerInternal + 0x7c
00007FFC8D5A9350 00007fca9a7e63b5 libcoreclr.so!CallDescrWorkerWithHandler(CallDescrData*, int) + 0x75, calling libcoreclr.so!CallDescrWorkerInternal
00007FFC8D5A9390 00007fca9a7e6e90 libcoreclr.so!MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int) + 0x4f0, calling libcoreclr.so!CallDescrWorkerWithHandler(CallDescrData*, int)
00007FFC8D5A93C0 00007fca9aacf80a libcoreclr.so!HeapFree + 0x3a, calling libcoreclr.so!PAL_free
00007FFC8D5A93E0 00007fca9aa4828a libcoreclr.so!MDInternalRO::GetSigOfMethodDef(unsigned int, unsigned int*, unsigned char const**) + 0x7a, calling libcoreclr.so!StgBlobPoolReadOnly::GetBlob(unsigned int, MetaData::DataBlob*)
00007FFC8D5A9420 00007fca9a79e972 libcoreclr.so!MetaSig::Init(unsigned char const*, unsigned int, Module*, SigTypeContext const*, MetaSig::MetaSigKind) + 0x2b2, calling libcoreclr.so!SigParser::SkipExactlyOne()
00007FFC8D5A9450 00007fca9a79ebfd libcoreclr.so!MetaSig::MetaSig(MethodDesc*, TypeHandle) + 0xed, calling libcoreclr.so!MethodDesc::RequiresInstArg()
00007FFC8D5A9560 00007fca9a8ca2d2 libcoreclr.so!RunMain(MethodDesc*, short, int*, PtrArray**) + 0x312, calling libcoreclr.so!MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int)
00007FFC8D5A9780 00007fca9a8ca5d0 libcoreclr.so!Assembly::ExecuteMainMethod(PtrArray**, int) + 0x110, calling libcoreclr.so!RunMain(MethodDesc*, short, int*, PtrArray**)
00007FFC8D5A9990 00007fca9a718694 libcoreclr.so!REGUTIL::GetConfigInteger(char16_t const*, unsigned long, unsigned long*, int, REGUTIL::CORConfigLevel, int) + 0x34, calling libcoreclr.so!REGUTIL::EnvGetString(char16_t const*, int)
00007FFC8D5A99E0 00007fca9a718761 libcoreclr.so!REGUTIL::GetConfigDWORD_DontUse_(char16_t const*, unsigned int, unsigned int*, REGUTIL::CORConfigLevel, int) + 0x31, calling libcoreclr.so!REGUTIL::GetConfigInteger(char16_t const*, unsigned long, unsigned long*, int, REGUTIL::CORConfigLevel, int)
00007FFC8D5A9A10 00007fca9a7176ec libcoreclr.so!CLRConfig::GetConfigValue(CLRConfig::ConfigDWORDInfo const&, bool, bool*) + 0x6c, calling libcoreclr.so!REGUTIL::GetConfigDWORD_DontUse_(char16_t const*, unsigned int, unsigned int*, REGUTIL::CORConfigLevel, int)
00007FFC8D5A9A90 00007fca9a735221 libcoreclr.so!CorHost2::ExecuteAssembly(unsigned int, char16_t const*, int, char16_t const**, unsigned int*) + 0x241, calling libcoreclr.so!Assembly::ExecuteMainMethod(PtrArray**, int)
00007FFC8D5A9B80 00007fca9a713b84 libcoreclr.so!coreclr_execute_assembly + 0xd4
00007FFC8D5A9BE0 00007fca9ae111b3 libhostpolicy.so!___lldb_unnamed_symbol110$$libhostpolicy.so + 0x2f3, calling libhostpolicy.so!___lldb_unnamed_symbol54$$libhostpolicy.so
00007FFC8D5A9C30 00007fca9bc3b869 libstdc++.so.6!std::condition_variable::notify_all() + 0x9, calling libstdc++.so.6!pthread_cond_broadcast
00007FFC8D5A9C40 00007fca9ae11f05 libhostpolicy.so!___lldb_unnamed_symbol116$$libhostpolicy.so + 0x165, calling libhostpolicy.so!std::condition_variable::notify_all()
00007FFC8D5A9C80 00007fca9ae11a0c libhostpolicy.so!corehost_main + 0xcc, calling libhostpolicy.so!___lldb_unnamed_symbol111$$libhostpolicy.so
00007FFC8D5A9D50 00007fca9b075620 libhostfxr.so!___lldb_unnamed_symbol382$$libhostfxr.so + 0x600
00007FFC8D5A9E00 00007fca9b06ba94 libhostfxr.so!___lldb_unnamed_symbol342$$libhostfxr.so + 0x144, calling libhostfxr.so!___lldb_unnamed_symbol343$$libhostfxr.so
00007FFC8D5A9E60 00007fca9b0743b3 libhostfxr.so!___lldb_unnamed_symbol380$$libhostfxr.so + 0x2b3, calling libhostfxr.so!___lldb_unnamed_symbol382$$libhostfxr.so
00007FFC8D5A9F40 00007fca9b06f603 libhostfxr.so!hostfxr_main_startupinfo + 0x93, calling libhostfxr.so!___lldb_unnamed_symbol380$$libhostfxr.so
00007FFC8D5A9FB0 000000000040c3f1 dotnet!___lldb_unnamed_symbol104$$dotnet + 0x311
---------------------------------------------
Thread 12
TEB information is not available so a stack size of 0xFFFF is assumed
Current frame: libpthread.so.0!__lll_lock_wait + 0x1d
Child-SP RetAddr Caller, Callee
00007FC9FBFFC3E8 00007fca9c09edcb libpthread.so.0!_L_lock_883 + 0xf, calling libpthread.so.0!__lll_lock_wait
00007FC9FBFFC430 00007fca9a7501eb libcoreclr.so!InlinedCallFrame::Init() + 0x3b, calling libcoreclr.so!Frame::PopIfChained()
00007FC9FBFFC470 00007fca9131d333 System.Native.so!SystemNative_ConfigureTerminalForChildProcess + 0x23, calling System.Native.so!pthread_mutex_lock
00007FC9FBFFC4A0 00007fca9a82dbfb libcoreclr.so!JIT_InitPInvokeFrame(InlinedCallFrame*, void*) + 0x2b, calling libcoreclr.so!InlinedCallFrame::Init()
00007FC9FBFFC4D0 00007fca214bf523 (MethodDesc 00007fca21a0ada0 + 0x73 ILStubClass.IL_STUB_PInvoke(Boolean))
00007FC9FBFFC510 00007fca214bf523 (MethodDesc 00007fca21a0ada0 + 0x73 ILStubClass.IL_STUB_PInvoke(Boolean))
00007FC9FBFFC560 00007fca21760dab (MethodDesc 00007fca21669668 + 0x2b System.Diagnostics.Process.ConfigureTerminalForChildProcesses(Int32)), calling 00007fca214bf1e0 (stub for Interop+Sys.ConfigureTerminalForChildProcess(Boolean))
00007FC9FBFFC580 00007fca2175dfe3 (MethodDesc 00007fca21669458 + 0x243 System.Diagnostics.Process.ForkAndExecProcess(System.String, System.String[], System.String[], System.String, Boolean, Boolean, Boolean, Boolean, UInt32, UInt32, UInt32[], Int32 ByRef, Int32 ByRef, Int32 ByRef, Boolean, Boolean)), calling 00007fca214b1b60 (stub for System.Diagnostics.Process.ConfigureTerminalForChildProcesses(Int32))
00007FC9FBFFC5B0 00007fca9a8b660c libcoreclr.so!ThePreStub + 0x5c, calling libcoreclr.so!PreStubWorker
00007FC9FBFFC6A0 00007fca2175cde5 (MethodDesc 00007fca21669440 + 0x195 System.Diagnostics.Process.StartCore(System.Diagnostics.ProcessStartInfo)), calling 00007fca217427a6
00007FC9FBFFC790 00007fca2175c61a (MethodDesc 00007fca21669098 + 0xfa System.Diagnostics.Process.Start()), calling 00007fca217427a6
00007FC9FBFFC7C0 00007fca214b2074 (MethodDesc 00007fca2156fde8 + 0x184 Test.ChildProcess.Start()), calling 00007fca214b1ed0 (stub for System.Diagnostics.Process.Start())
00007FC9FBFFC840 00007fca214c6fbc (MethodDesc 00007fca2156fe28 + 0x2c Test.ChildProcess.<Process_Exited>b__6_0()), calling (MethodDesc 00007fca2156fde8 + 0 Test.ChildProcess.Start())
00007FC9FBFFC860 00007fca20fc5242 (MethodDesc 00007fca21bd79b8 + 0x32 System.Threading.ThreadHelper.ThreadStart_Context(System.Object))
00007FC9FBFFC880 00007fca20fcea81 (MethodDesc 00007fca21919d88 + 0x81 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
00007FC9FBFFC8D0 00007fca20fc535e (MethodDesc 00007fca21bd7a00 + 0x2e System.Threading.ThreadHelper.ThreadStart()), calling 00007fca214bc2e0 (stub for System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
00007FC9FBFFC8F0 00007fca9a8b595f libcoreclr.so!CallDescrWorkerInternal + 0x7c
00007FC9FBFFC910 00007fca9a7e63b5 libcoreclr.so!CallDescrWorkerWithHandler(CallDescrData*, int) + 0x75, calling libcoreclr.so!CallDescrWorkerInternal
00007FC9FBFFC950 00007fca9a7e6e90 libcoreclr.so!MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int) + 0x4f0, calling libcoreclr.so!CallDescrWorkerWithHandler(CallDescrData*, int)
00007FC9FBFFC9D0 00007fca9a8e4e51 libcoreclr.so!ClassLoader::LoadTypeHandleThrowing(NameHandle*, ClassLoadLevel, Module*) + 0x2f1, calling libcoreclr.so!ClassLoader::LoadTypeDefThrowing(Module*, unsigned int, ClassLoader::NotFoundAction, ClassLoader::PermitUninstantiatedFlag, unsigned int, ClassLoadLevel, Instantiation*)
00007FC9FBFFCB18 00007fc9fbffccb0 00007fc9fbffccb0, calling 00007fc9fc004c79
00007FC9FBFFCB20 00007fca9a7f1183 libcoreclr.so!ThreadNative::KickOffThread_Worker(void*) + 0x1d3, calling libcoreclr.so!MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int)
00007FC9FBFFCCB0 00007fca9a7b9225 libcoreclr.so!ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) + 0x155
00007FC9FBFFCCD0 00007fca9a7392f9 libcoreclr.so!CrstBase::Leave() + 0x29
00007FC9FBFFCCE0 00007fca9a737e74 libcoreclr.so!CExecutionEngine::GetTlsData() + 0x14, calling libcoreclr.so!__tls_get_addr
00007FC9FBFFCD60 00007fca9a7b219c libcoreclr.so!Thread::HasStarted(int) + 0x1fc, calling libcoreclr.so!CLRException::HandlerState::CleanupTry()
00007FC9FBFFCDD0 00007fca9a7b983d libcoreclr.so!ManagedThreadBase::KickOff(void (*)(void*), void*) + 0x2d, calling libcoreclr.so!ManagedThreadBase_DispatchOuter(ManagedThreadCallState*)
00007FC9FBFFCE00 00007fca9a7f13f1 libcoreclr.so!ThreadNative::KickOffThread(void*) + 0x171, calling libcoreclr.so!ManagedThreadBase::KickOff(void (*)(void*), void*)
00007FC9FBFFCEB0 00007fca9aaf043d libcoreclr.so!CorUnix::CPalThread::ThreadEntry(void*) + 0x15d
00007FC9FBFFCF70 00007fca9b3a302d libc.so.6!__clone + 0x6d
Hi, I have sample application with two threads - first one reads from stdin, second starts new child process, when old one is terminated.
It worked fine in netcoreapp2.2 both in windows and linux, netcoreapp3.0 preview7 at windows. However it doesn't work in preview7 at linux(RHEL7.6).
Actual behavior
Child process is started at the beginning(before Console.ReadLine). In the next attempt Process.Start is blocked by pthread_mutex used in Console.ReadLine.
Expected behavior
New child process is started, when previous child was terminated.
Code to reproduce
https://gist.github.com/jirinyms/3e2e422a5cb32a8c23f5f7cc487fdd4f
lldb dump