Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. VS 2008 Debugger going crazy?

VS 2008 Debugger going crazy?

Scheduled Pinned Locked Moved Clever Code
debuggingvisual-studiocomregexquestion
12 Posts 7 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abhigad
    wrote on last edited by
    #1

    Look at the simple code below

    using System;
    namespace Pattern
    {
    class Program
    {
    static void Main(string[] args)
    {
    Singleton s1, s2;

            s1 = Singleton.getSingletonInstance();
    
            s1.instanceCount = 100;
    
            s2 = Singleton.getSingletonInstance();
        }
    }
    sealed class Singleton
    {
        private static Singleton \_s = null;
        public int instanceCount;
    
        private Singleton()
        {
            //do nothing
        }
    
        public static Singleton getSingletonInstance()
        {
            if (\_s == null)
            {
                \_s = new Singleton();
            }
    
            return \_s;
        }
    
    }
    

    }

    Put the breakpoint on line if (_s == null) and then observe the behavior when we do something like s2 = Singleton.getSingletonInstance(); When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?

    L P P M 4 Replies Last reply
    0
    • A abhigad

      Look at the simple code below

      using System;
      namespace Pattern
      {
      class Program
      {
      static void Main(string[] args)
      {
      Singleton s1, s2;

              s1 = Singleton.getSingletonInstance();
      
              s1.instanceCount = 100;
      
              s2 = Singleton.getSingletonInstance();
          }
      }
      sealed class Singleton
      {
          private static Singleton \_s = null;
          public int instanceCount;
      
          private Singleton()
          {
              //do nothing
          }
      
          public static Singleton getSingletonInstance()
          {
              if (\_s == null)
              {
                  \_s = new Singleton();
              }
      
              return \_s;
          }
      
      }
      

      }

      Put the breakpoint on line if (_s == null) and then observe the behavior when we do something like s2 = Singleton.getSingletonInstance(); When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      LOL, I havent seen that one before (for those that do not understand, look at screenshot). In some debugging scenarios I have had VS flashing like a disco :)

      1 Reply Last reply
      0
      • A abhigad

        Look at the simple code below

        using System;
        namespace Pattern
        {
        class Program
        {
        static void Main(string[] args)
        {
        Singleton s1, s2;

                s1 = Singleton.getSingletonInstance();
        
                s1.instanceCount = 100;
        
                s2 = Singleton.getSingletonInstance();
            }
        }
        sealed class Singleton
        {
            private static Singleton \_s = null;
            public int instanceCount;
        
            private Singleton()
            {
                //do nothing
            }
        
            public static Singleton getSingletonInstance()
            {
                if (\_s == null)
                {
                    \_s = new Singleton();
                }
        
                return \_s;
            }
        
        }
        

        }

        Put the breakpoint on line if (_s == null) and then observe the behavior when we do something like s2 = Singleton.getSingletonInstance(); When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Well of course, what else should it do? :confused: This does the same thing:

        public class X
        {
        public X x ;

        public X() { x = this ; }
        

        }

        And I hope you've read this[^].

        A 1 Reply Last reply
        0
        • P PIEBALDconsult

          Well of course, what else should it do? :confused: This does the same thing:

          public class X
          {
          public X x ;

          public X() { x = this ; }
          

          }

          And I hope you've read this[^].

          A Offline
          A Offline
          abhigad
          wrote on last edited by
          #4

          Two things The code sample in this explanation [i.e. public class X] is not showing the same behavior. Don’t think it is because of the singleton. In fact, same behavior is visible in other scenarios. Accepted, it is doing some sort of circular referencing. Question is why and where? Anyways, the article on singleton is very good.

          P 1 Reply Last reply
          0
          • A abhigad

            Two things The code sample in this explanation [i.e. public class X] is not showing the same behavior. Don’t think it is because of the singleton. In fact, same behavior is visible in other scenarios. Accepted, it is doing some sort of circular referencing. Question is why and where? Anyways, the article on singleton is very good.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            abhigad wrote:

            not showing the same behavior

            Seemed to for me.

            abhigad wrote:

            where?

            _s refers to an instance of the class, which contains _s. At any rate, this is not the proper forum for this.

            1 Reply Last reply
            0
            • A abhigad

              Look at the simple code below

              using System;
              namespace Pattern
              {
              class Program
              {
              static void Main(string[] args)
              {
              Singleton s1, s2;

                      s1 = Singleton.getSingletonInstance();
              
                      s1.instanceCount = 100;
              
                      s2 = Singleton.getSingletonInstance();
                  }
              }
              sealed class Singleton
              {
                  private static Singleton \_s = null;
                  public int instanceCount;
              
                  private Singleton()
                  {
                      //do nothing
                  }
              
                  public static Singleton getSingletonInstance()
                  {
                      if (\_s == null)
                      {
                          \_s = new Singleton();
                      }
              
                      return \_s;
                  }
              
              }
              

              }

              Put the breakpoint on line if (_s == null) and then observe the behavior when we do something like s2 = Singleton.getSingletonInstance(); When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              B P 2 Replies Last reply
              0
              • P Pete OHanlon

                It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".

                Deja View - the feeling that you've seen this post before.

                My blog | My articles

                B Offline
                B Offline
                Brady Kelly
                wrote on last edited by
                #7

                I doubt the OP posted looking for help.

                P 1 Reply Last reply
                0
                • P Pete OHanlon

                  It's not exactly a subtle bug is it? Despite this being called the subtle bugs forum, and not the "let's try to get somebody to sort my problems out for me forum".

                  Deja View - the feeling that you've seen this post before.

                  My blog | My articles

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #8

                  Not sure of the OP's real intent. Too hard to tell today :laugh:

                  "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  1 Reply Last reply
                  0
                  • B Brady Kelly

                    I doubt the OP posted looking for help.

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #9

                    Brady Kelly wrote:

                    I doubt the OP posted looking for help

                    From the OP: "Any clue why?". It's at the bottom of his post.

                    Deja View - the feeling that you've seen this post before.

                    My blog | My articles

                    B 1 Reply Last reply
                    0
                    • P Pete OHanlon

                      Brady Kelly wrote:

                      I doubt the OP posted looking for help

                      From the OP: "Any clue why?". It's at the bottom of his post.

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles

                      B Offline
                      B Offline
                      Brady Kelly
                      wrote on last edited by
                      #10

                      It took you this long to find that evidence? Methinks Pete doth protest too much. ;P

                      Unscrambling Eggs: Decompiling ASP.NET

                      P 1 Reply Last reply
                      0
                      • B Brady Kelly

                        It took you this long to find that evidence? Methinks Pete doth protest too much. ;P

                        Unscrambling Eggs: Decompiling ASP.NET

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        Brady Kelly wrote:

                        Methinks Pete doth protest too much.

                        :laugh: Methinks Pete switches email notifications off.

                        Deja View - the feeling that you've seen this post before.

                        My blog | My articles

                        1 Reply Last reply
                        0
                        • A abhigad

                          Look at the simple code below

                          using System;
                          namespace Pattern
                          {
                          class Program
                          {
                          static void Main(string[] args)
                          {
                          Singleton s1, s2;

                                  s1 = Singleton.getSingletonInstance();
                          
                                  s1.instanceCount = 100;
                          
                                  s2 = Singleton.getSingletonInstance();
                              }
                          }
                          sealed class Singleton
                          {
                              private static Singleton \_s = null;
                              public int instanceCount;
                          
                              private Singleton()
                              {
                                  //do nothing
                              }
                          
                              public static Singleton getSingletonInstance()
                              {
                                  if (\_s == null)
                                  {
                                      \_s = new Singleton();
                                  }
                          
                                  return \_s;
                              }
                          
                          }
                          

                          }

                          Put the breakpoint on line if (_s == null) and then observe the behavior when we do something like s2 = Singleton.getSingletonInstance(); When the breakpoint will hit, try watching the value of _s. The watch window will pop endlessly all over the screen when you click on the following + sign next to the static members icon. Screenshot : http://bp1.blogger.com/_J8sDhLDCDXA/SHv7z5Sx0RI/AAAAAAAAAIA/8xubz88GBJM/s1600-h/debugger.JPG Any clue why?

                          M Offline
                          M Offline
                          Megidolaon
                          wrote on last edited by
                          #12

                          Judging by the screenshot, I assumed VS would open the watch windows by itself ;P Anyway, for my it just crashed after opening what was apparently one too many of these watch windows. I did have other cases where something similar happened, but I don't think I have still have the code, it's already fixed.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups