mohanak12 / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 1 forks source link

Gallio message pump should run in a separate thread execution context instead of using direct callbacks. #557

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Create some code that uses Impersonation
2.  Create a unit test using the impersonation code.
3.  Write some console messages while impersonating
4.  Run the unit test in Cruise Control.Net (as a service)

What is the expected output? What do you see instead?
The test should success, in stead there is an exception:

                        error: Internal error: An unhandled exception 
occurred while 
asynchronously publishing a queued message. 
The exception occurred while test step 'UnitTests/TestImpersonateUser/ 
TestImpersonateGenericId' was running. 
System.Runtime.Remoting.RemotingException: Failed to connect to an IPC 
Port: Access is denied. 

Server stack trace: 
   at System.Runtime.Remoting.Channels.Ipc.IpcPort.Connect(String 
portName, Boolean secure, TokenImpersonationLevel impersonationLevel, 
Int32 timeout) 
   at 
System.Runtime.Remoting.Channels.Ipc.ConnectionCache.GetConnection 
(String portName, Boolean secure, TokenImpersonationLevel level, Int32 
timeout) 
   at 
System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage 
(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, 
ITransportHeaders& responseHeaders, Stream& responseStream) 
   at 
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessa­
ge 
(IMessage msg) 

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage 
(IMessage reqMsg, IMessage retMsg) 
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke 
(MessageData& msgData, Int32 type) 
   at Gallio.Common.Messaging.RemoteMessageSink.Forwarder.Publish 
(Message message) 
   at Gallio.Common.Messaging.RemoteMessageSink.Publish(Message 
message) in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio 
\Common\Messaging\RemoteMessageSink.cs:line 52 
   at Gallio.Common.Messaging.QueuedMessageSink.AsyncPublishLoop() in 
c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common\Messaging 
\QueuedMessageSink.cs:line 120 
Reported by: 
UnhandledExceptionPolicy 
   at Gallio.Common.Messaging.QueuedMessageSink.AsyncPublishLoop() in 
c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common\Messaging 
\QueuedMessageSink.cs:line 124 
   at 
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage 
(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean 
fExecuteInContext, Object[]& outArgs) 
   at 
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage 
(RuntimeMethodHandle md, Object[] args, Object server, Int32 
methodPtr, Boolean fExecuteInContext, Object[]& outArgs) 
   at 
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage 
(IMessage msg, IMessageSink replySink) 
   at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall 
() 
   at 
System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack 
(Object o) 
   at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context 
(Object state) 
   at System.Threading.ExecutionContext.runTryCode(Object userData) 
   at 
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCle­
anup 
(TryCode code, CleanupCode backoutCode, Object userData) 
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext 
executionContext, ContextCallback callback, Object state) 
   at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state) 
   at 
System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal 
(_ThreadPoolWaitCallback tpWaitCallBack) 
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback 
(Object state) 

What version of the product are you using? On what operating system?
Gallio 3.1.313.0

Please provide any additional information below.

Unit tests run fine as a user.  They fail when run under Cruise 
Control.Net.  Removing any Console.WriteLines from inside the 
Impersonation context stops the exception from occurring.

Jeff Brown said the following about the bug:

Ahh. This is a bug that has to do with how we pump messages across   
appdomains. 

The workaround for now is to ensure that you do not write any messages   
to the test log while inside the impersonation context. 

Please open up an issue to remind me to fix this for v3.1 update.  I   
was going to put it off to v3.2 but there is no sense waiting that long. 

Jeff 

Original issue reported on code.google.com by sean.co...@gmail.com on 9 Oct 2009 at 12:16

GoogleCodeExporter commented 9 years ago

Original comment by jeff.br...@gmail.com on 9 Oct 2009 at 8:38

GoogleCodeExporter commented 9 years ago
Will wait for v3.2 after all.  v3.1 update has been delayed long enough.

Original comment by jeff.br...@gmail.com on 23 Oct 2009 at 7:11

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 22 Jul 2010 at 7:27

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 14 Jun 2011 at 5:53