PC Review


Reply
Thread Tools Rate Thread

Deadlock in XmlSerializer when using RedirectStandardInput

 
 
=?Utf-8?B?TWluZXJEZXY=?=
Guest
Posts: n/a
 
      15th Feb 2007
I have encountered a situation where a thread (say, thread-1) blocks for 10
minutes in an XmlSerializer constructor. This occurs when another thread
(say, thread-2) is blocked in a call to Console.ReadLine and the process was
created using System.Diagnostics.Process with RedirectStandardInput = true.
In this situation not only does thread-1 block for 10 min in the
XmlSerializer constructor, but will hang indefinitely when creating a COM
object.

The problem started occuring after migrating our application to .NET v2.0.

I found a forum post where some other developers have run into the exact
same problem. Please see this link:
http://forums.microsoft.com/MSDN/Sho...88895&SiteID=1 (it
also includes a reproducible testcase)

Is anyone aware of a decent workaround to this issue (or a fix available
..NET 2.0)? I seems that this problem greatly limits the usefulness of stdin
redirection.

BACKGROUND INFO

We need to run multiple instances of an console application (it runs until
told to stop). Since we need to run more than one process on a single machine
it did not make sense to make the application a windows service. Instead, we
developed a windows services that spawns these (child) application processes.
Using the System.Diagnostics.Process class we can not only spawn the process,
but also interact with it via stdin and stdout.

OTHER NOTES (not-so-nice workarounds)

It appears that the XmlSerializer hangs in the call to csc.exe (you can see
this child process using ProcessExplorer). I can get around this problem by
sgen'ing the assembly which eliminates the need for spawning csc.exe at
runtime. However, this doesn't fix the problem with creating COM objects.

Another workaround i've seen (see forum post mentioned above) is to not call
Console.ReadLine() in the child process. However, I need this call in order
to process interactive commandline input. Also note the call to ReadLine is
on an MTA thread to avoid STA "pumping" issues, so the deadlock/contention is
occuring on some other resource.
 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      16th Feb 2007
Hi,

I've been able to reproduce the issue on XP and it indeed works ok on
Vista. Since I've also installed .NET 3.0 on XP, it's unlikely can be fixed
by installing .NET 3.0 as conclued in the forum post you mentioned.

I'm currently consulting this question in our internal discussion list to
see if there's any hotfix for it on pre-Vista OS. I'll get back to you as
soon as I get updated information. Thank you for your patience and
understanding.

Sincerely,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      23rd Feb 2007
Hi,

I've sent an email to you on Feb. 20. Since I didn't received your reply
yet I'm wondering if the email address is correct or not. Would you please
send me an email when you see this? Thank you.

Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Luke Zhang [MSFT]
Guest
Posts: n/a
 
      1st Mar 2007
Hello,

I am reviewing this post. I found Walter has reproduced the and want to
involve more resource to find a proper solution on this issue. To better
communicate on this issue and find a final solution, would you please let
us know your actual email address? To get my email, please remove "online"
from my display email.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.



 
Reply With Quote
 
Hans-Jürgen Arbogast
Guest
Posts: n/a
 
      1st Mar 2007
Hello,

I am concerned by a very similar deadlock. I start a console-application via
Process.Start (RedirectStandardInput = true). The console application
executes a Console.Readline. In another thread, the program accesses a
SingleThreaded COM componente. Accessing the COM component deadlocks.

I am wondering how to fix this. If I omit the Console.ReadLine call, the
code does not deadlock.

Can anybody please explain, what is going on here.

Kind Regards,
Hans-Jürgen.


ntdll.dll!_KiFastSystemCallRet@0()
ntdll.dll!_ZwWaitForSingleObject@12() + 0xc bytes
kernel32.dll!_WaitForSingleObjectEx@12() + 0x8b bytes
kernel32.dll!_WaitForSingleObject@8() + 0x12 bytes
ole32.dll!GetToSTA() + 0x4e bytes
ole32.dll!CRpcChannelBuffer::SwitchAptAndDispatchCall() + 0xccf bytes
ole32.dll!CRpcChannelBuffer::SendReceive2() + 0x76 bytes
ole32.dll!CAptRpcChnl::SendReceive() + 0x46 bytes
ole32.dll!CCtxComChnl::SendReceive() + 0x43 bytes
rpcrt4.dll!_NdrProxySendReceive@8() + 0x40 bytes
rpcrt4.dll!_NdrClientCall2() + 0x9dc bytes
rpcrt4.dll!_ObjectStublessClient@8() + 0x5d bytes
rpcrt4.dll!_ObjectStubless@0() + 0xf bytes
ole32.dll!CStdMarshal::Begin_RemQIAndUnmarshal1() + 0x91 bytes
ole32.dll!CStdMarshal::Begin_QueryRemoteInterfaces() + 0x37 bytes
ole32.dll!CStdMarshal::QueryRemoteInterfaces() + 0x37 bytes
ole32.dll!CStdIdentity::CInternalUnk::QueryMultipleInterfaces() + 0xce65
bytes
ole32.dll!CStdIdentity::CInternalUnk::QueryInterface() + 0x30 bytes
[Managed to Native Transition]
>>>... here is my code, accessing the COM object.


"Luke Zhang [MSFT]" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Hello,
>
> I am reviewing this post. I found Walter has reproduced the and want to
> involve more resource to find a proper solution on this issue. To better
> communicate on this issue and find a final solution, would you please let
> us know your actual email address? To get my email, please remove "online"
> from my display email.
>
> Sincerely,
>
> Luke Zhang
>
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>



 
Reply With Quote
 
Hans-Jürgen Arbogast
Guest
Posts: n/a
 
      1st Mar 2007
Oh, excuse me, I forget to mention, that I attached a unmanaged call-stack
of the point where the code is freezing.


"Hans-Jürgen Arbogast" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Hello,
>
> I am concerned by a very similar deadlock. I start a console-application
> via Process.Start (RedirectStandardInput = true). The console application
> executes a Console.Readline. In another thread, the program accesses a
> SingleThreaded COM componente. Accessing the COM component deadlocks.
>
> I am wondering how to fix this. If I omit the Console.ReadLine call, the
> code does not deadlock.
>
> Can anybody please explain, what is going on here.
>
> Kind Regards,
> Hans-Jürgen.
>
>
> ntdll.dll!_KiFastSystemCallRet@0()
> ntdll.dll!_ZwWaitForSingleObject@12() + 0xc bytes
> kernel32.dll!_WaitForSingleObjectEx@12() + 0x8b bytes
> kernel32.dll!_WaitForSingleObject@8() + 0x12 bytes
> ole32.dll!GetToSTA() + 0x4e bytes
> ole32.dll!CRpcChannelBuffer::SwitchAptAndDispatchCall() + 0xccf bytes
> ole32.dll!CRpcChannelBuffer::SendReceive2() + 0x76 bytes
> ole32.dll!CAptRpcChnl::SendReceive() + 0x46 bytes
> ole32.dll!CCtxComChnl::SendReceive() + 0x43 bytes
> rpcrt4.dll!_NdrProxySendReceive@8() + 0x40 bytes
> rpcrt4.dll!_NdrClientCall2() + 0x9dc bytes
> rpcrt4.dll!_ObjectStublessClient@8() + 0x5d bytes
> rpcrt4.dll!_ObjectStubless@0() + 0xf bytes
> ole32.dll!CStdMarshal::Begin_RemQIAndUnmarshal1() + 0x91 bytes
> ole32.dll!CStdMarshal::Begin_QueryRemoteInterfaces() + 0x37 bytes
> ole32.dll!CStdMarshal::QueryRemoteInterfaces() + 0x37 bytes
> ole32.dll!CStdIdentity::CInternalUnk::QueryMultipleInterfaces() + 0xce65
> bytes
> ole32.dll!CStdIdentity::CInternalUnk::QueryInterface() + 0x30 bytes
> [Managed to Native Transition]
>>>>... here is my code, accessing the COM object.

>
> "Luke Zhang [MSFT]" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
>> Hello,
>>
>> I am reviewing this post. I found Walter has reproduced the and want to
>> involve more resource to find a proper solution on this issue. To better
>> communicate on this issue and find a final solution, would you please let
>> us know your actual email address? To get my email, please remove
>> "online"
>> from my display email.
>>
>> Sincerely,
>>
>> Luke Zhang
>>
>> Microsoft Online Community Support
>> ==================================================
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscripti...ult.aspx#notif
>> ications.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscripti...t/default.aspx.
>> ==================================================
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deadlock in XmlSerializer when using RedirectStandardInput =?Utf-8?B?TWluZXJEZXY=?= Microsoft Dot NET Framework 0 7th Feb 2007 10:16 PM
Process - RedirectStandardInput =?Utf-8?B?cGh5emljcw==?= Microsoft Dot NET Framework 0 16th Nov 2004 12:15 AM
Process.RedirectStandardInput Question Matt Osborne Microsoft C# .NET 4 30th Jun 2004 07:14 PM
Re: RedirectStandardInput Christopher Kimbell Microsoft Dot NET Framework 1 18th Jun 2004 07:11 PM
Process RedirectStandardInput =?Utf-8?B?Sm9l?= Microsoft C# .NET 1 15th Mar 2004 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:03 PM.