Strangest bug ever!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Thread: Strangest bug ever!

Hybrid View

  1. #1
    Join Date
    Aug 2012
    Posts
    8

    Strangest bug ever!

    Alright, here is my piece of code :

    Code:
    long *a = &(cgm.o->m_metafileVersion);
    I put a break point at the following instruction and when I look in the watch section of visual C++ 2010, I have that :

    a = 0x053e3d50
    &(cgm.o->m_metafileVersion) = 0x053e3d28

    weird, isn't it?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    Why?
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    Why it is weird?

    because "a" is a pointer and it get the adresse of cgm.o->m_metafileVersion.... so unless I woke up in a parallel world, where the C++ rules would be different, "long *a" should be equal to "&(cgm.o->m_metafileVersion)"... and it's not (!!!)


  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    When did you look in the watch section: before or after this line had been executed?
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    after! I put a break point at the following instruction.

  6. #6
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    yeah I know it's weird... but I don't even know, who can I speak to to get help...

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    Quote Originally Posted by ArnaudCas View Post
    yeah I know it's weird... but I don't even know, who can I speak to to get help...
    I did a very simple test:
    Code:
    class CTest
    {
    public:
    	long m_metafileVersion;
    	CTest()	{m_metafileVersion = 0;}
    };
    class CGm
    {
    public:
    	CTest o;
    	int something;
    	CGm()	{something = 0;}
    };
    
    	CGm cgm;
    	long *a = &(cgm.o.m_metafileVersion);
    What I see in the watch window is:
    Code:
    	&(cgm.o.m_metafileVersion)		0x0012f4a8	long *
    	a					0x0012f4a8	long *
    The only difference I see is: I use the object o while you use some pointer o.
    Where does it point to?
    Victor Nijegorodov

  8. #8
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    errh, the object "o" points to a data structure, a class, from the library I use (it's a lib to read cgm files)
    Do you think the lib has a problem? or my EDI (Visual Studio)?

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    I don't know.
    I tested in
    Microsoft Visual Studio 2010
    Version 10.0.40219.1 SP1Rel
    Microsoft .NET Framework
    Version 4.0.30319 SP1Rel

    Installed Version: Ultimate
    ....
    Microsoft Visual C++ 2010 01019-532-2002102-70738
    Microsoft Visual C++ 2010
    ....
    Hotfix for Microsoft Visual Studio 2010 Ultimate - ENU (KB2548139) KB2548139
    This hotfix is for Microsoft Visual Studio 2010 Ultimate - ENU.
    If you later install a more recent service pack, this hotfix will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/2548139.

    Hotfix for Microsoft Visual Studio 2010 Ultimate - ENU (KB2565057) KB2565057
    This hotfix is for Microsoft Visual Studio 2010 Ultimate - ENU.
    If you later install a more recent service pack, this hotfix will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/2565057.

    Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.40219
    Microsoft Visual Studio 2010 SharePoint Developer Tools

    Microsoft Visual Studio 2010 Ultimate - ENU Service Pack 1 (KB983509) KB983509
    This service pack is for Microsoft Visual Studio 2010 Ultimate - ENU.
    If you later install a more recent service pack, this service pack will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/983509.

    Security Update for Visual Studio 2010 Shell (Isolated) - ENU (KB2644980) KB2644980
    This security update is for Visual Studio 2010 Shell (Isolated) - ENU.
    If you later install a more recent service pack, this security update will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/2644980.
    Victor Nijegorodov

  10. #10
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    I dont see what I have to do with your links.
    I tested the lib in a new simple main program, and I have the error too. So Maybe it comes from the lib, but how? The error seems to come from the IDE, nevertheless, right?

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    Quote Originally Posted by ArnaudCas View Post
    I dont see what I have to do with your links.
    Just compare it with your VS2010 installation data.

    Quote Originally Posted by ArnaudCas View Post
    I tested the lib in a new simple main program, and I have the error too. So Maybe it comes from the lib, but how? The error seems to come from the IDE, nevertheless, right?
    I don't know, sorry.
    Victor Nijegorodov

  12. #12
    Join Date
    Oct 2008
    Posts
    1,077

    Re: Strangest bug ever!

    Quote Originally Posted by ArnaudCas View Post
    The error seems to come from the IDE, nevertheless, right?
    what error ? we can have no idea if it is a program bug ( highly plausible ), a compiler bug ( highly unplausible ) or a debugger glitch by just looking at a single line of apparently correct code.

    BTW, note that this forum is for visual studio bugs, not yours. As said above, it's highly implausible that the compiler breaks such a basic statement. It's highly plausible that you made a mistake somewhere in your program that reproduces the observed behavior, or that you're improperly using the debugger.

    Now, to exclude the possibility of a debugger viewer bug, place an "_ASSERT( a == &(cgm.o->m_metafileVersion) );" at the break point. If this gives a runtime error, ask a moderator to move the thread to the Visual C++ Programming forum; then, post the smallest but complete piece of code capable of reproducing the problem.

  13. #13
    Join Date
    Aug 2012
    Posts
    8

    Re: Strangest bug ever!

    I tried and there is no runtime error.

    as I told you,
    Code:
    long *l = &(cgm.o->m_metafileVersion);
    doesn't work as it should be, that's why I try to find help here. I don't understand.

    I've got a class with a pointer to an object from the lib I use to read CGM files :

    Code:
    class CGM
    {
    public: 
    	CCgmObjects *o;
    
    public :
    	CGM():o(NULL){}
    	~CGM(){if(o)delete o;}
    	int load(const char* pFilename);
    };
    I load it with that function :
    Code:
        int CGM::load(const char* pFilename){
    
    	CConfig  *pConfig = new CConfig();
    	if (pConfig != 0)
    	{
    		// create a CgmObjects instance and Load the CGM file
    		o = new CCgmObjects(pConfig, NULL);
    			
    		if (o != 0)
    		{
    			std::string userFontsDir = ".";
    			// Load the CGM file
    			error = o->LoadFile(pFilename);
    				
    			if (error != 0) 
    			{
    				printf("cannot open the file");
    			}
    	} 
       }
    but, again, it's not a programing problem. It's like if it is a Visual C++'s bug. The visual installation seems to be good...
    Maybe there is a param or something in the project configuration?

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,011

    Re: Strangest bug ever!

    Quote Originally Posted by ArnaudCas View Post
    Code:
    long *l = &(cgm.o->m_metafileVersion);
    doesn't work as it should be, that's why I try to find help here. I don't understand.
    1. How should it work and how does it work?
    2. Your code snippet does not contain the line you referred to.
    3. Did you try with ASSERT as superbonzo suggested?
    Victor Nijegorodov

  15. #15
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    7,994

    Re: Strangest bug ever!

    I have taken a look in my crystal ball and saw a parallel world in which somebody is trying to Debug in a Release build.
    Pretty weird, isn't it?
    Last edited by ovidiucucu; August 31st, 2012 at 02:50 AM.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center