Alexis Smirnov
Thinking about software




Tuesday, November 19, 2002
 

Gavin Williams details accidental CLR backdoors on DOTNET-CLR list

Here's the problem in a nutshell: Because class instances are always
passed by reference and are often mutable, it is very easy to
accidentally create back doors in your classes, causing:

1. Unexpected changes in internal state
2. Race conditions in methods executing asynchronously
3. Modification of properties you thought were read-only
("immutability leakage", a special case of #1)

He gives an example of problem #3 in System.Net code:

using System.Net;
class Main
        {
        static void Main(string[] args)
                {
                IPAddress ip = IPAddress.Loopback;

                // Do something interesting with ip...

                // Now set a new value
                ip.Address = 2345235;

                // Congratulations!
                // You've just changed IPAddress.Loopback to
                // 19.201.35.0
                // and broken the IPAddress.IsLoopback method.
                }
        }

So far, the discussion on the list offers no solutions to what appers to be pretty serious problem.


    


Subscribe to "Alexis Smirnov" in Radio UserLand. Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.
Site Statistics
© Copyright 2003 Alexis Smirnov.


Last update: 5/6/2003; 5:42:52 PM.

November 2002
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Oct   Dec

Aug 2002