[Mono-winforms-list] [PATCH] Stack propagation for Control.BeginInvoke

Peter Dennis Bartok peter@novonyx.com
Thu May 12 00:43:34 EDT 2005


I've modified the patch slightly and commited it (r44415). I took care of 
the fixme, Invoke() no longer calls Begin/EndInvoke() if it's not needed, 
and I've moved the ExecuteClientMessage code into a new class 
XplatUIDriverSupport, to allow usage by all drivers. I've also made the 
Win32 driver use it.

Thanks!

 Cheers,
  Peter

-----Original Message-----
From: "Sebastien Pouliot" <sebastien@ximian.com>
To: "Mono WinForms List" <mono-winforms-list@lists.ximian.com>
Date: 11 May, 2005 15:20
Subject: [Mono-winforms-list] [PATCH] Stack propagation for 
Control.BeginInvoke


>Hello,
>
>Here's a patch to enabled stack propagation to work for
>Control.BeginInvoke. For people who wonder what stack propagation is,
>here's a short explanation...
>
>        Stack propagation ensure that Code Access Security (CAS)
>        permissions can work across threads for asynchronous calls. This
>        ensure that code cannot be given more privileges because it's
>        being executed by another thread (which wouldn't have all the
>        restrictions that the original thread may have).
>
>A test case is available in SVN under:
> /mono/mono/tests/cas/threads/swf-control1.cs
>
>The sample code shows that the "main" code is restricted from reading
>the username. Which means that the "invoked" code (via Control.
>BeginInvoke) should also have the same restriction (even if it's being
>executed in the control's thread).
>
>
>* If you execute the sample "normally" you should see the
>SecurityManager status, the current time and your username for a few
>seconds.
>
>% mono swf-control1.exe
>
>
>* Additional debugging output can be displayed by adding a(ny)
>parameters on the command-line.
>
>% mono swf-control1.exe x
>
>
>* If you execute it with the security manager enabled the username will
>be replaced (well if the patch is applied ;-) by "SecurityException".
>
>% mono --security swf-control1.exe x
>
>
>Notes:
>
>* The current patch is only for the X11 driver, but it shouldn't be hard
>to port to the other drivers (or to move elsewhere);
>
>* Stack propagation only occurs if the security manager is active (i.e.
>--security) so it's impact should be minimal (even invisible) for most
>users;
>
>* The code is a little different for the Fx 2.0 because propagation
>isn't only done for the security stack (a lot of other contexts are
>also, or will be, propagated). The code looks different but still the
>_stack_ propagation is only done if the security manager is active;
>
>* About the sample, it's window should close itself after
>Application.Exit is called. However it seems to wait for the next X
>event (mouse, keyboard) to do so. This works normally under Windows and
>isn't related to my patch;
>
>* The sample shouldn't hang after the Application.Exit call (and closing
>the Windows). However it does hang (for me) or, sometimes, display a
>NullReferenceException. This also works normally under Windows and I
>don't think it's related to the patch (but it may be related to recent
>thread shutdown problems);
>
>* Of course Control.BeginInvoke is only a (small) subset of the work
>required to complete stack propagation - but most of it will occur
>outside SWF.
>
>-- 
>Sebastien Pouliot  <sebastien@ximian.com>
>blog: http://pages.infinit.net/ctech/poupou.html
> 




More information about the Mono-winforms-list mailing list