0

I am trying to step through a C/C++ program (MapServer) in Visual Studio, but I cannot see the local variables.

I created a new project by adding the main .exe I built from source. I can set break points and step through the program without problem, but I cannot see what is stored in any of the variables. I am running all this on a Virtual Machine - the host OS is Windows 10, and the VM is Windows 7.

The program is:

  • built as a debug release
  • has no optimizations
  • the symbols load fine

I am fairly certain it is due to it being a x64 bit release, as I can use the exact same approach for a x32 build and see the variables.

Example of the x32 debugger (the first 5 variables are correct - the others are unset):

Working debug session

Example of x64 debug session (note the program works fine):

Failing session

I thought it may be due to VS2008, so I also tried in VS2015, but had similar (failing) results:

enter image description here

Trying to access variables in the Immediate Window produces:

// working VS2008 x32 build
map->name
0x00ffcb40 "WFS_server"

// VS2008 x64 build
map->name
0x0000000000000000 <Bad Ptr>

// VS2015 x64 build
map->name  
0x0000000000000000 <NULL>

Am I missing some debugger setting in Visual Studio to set the debug project to x64? Or is there some casting issue in the source code that produces this?

Any pointers appreciated..

geographika
  • 6,458
  • 4
  • 38
  • 56
  • You may want to try to repair your VS installation (Programs and features -> VS -> Modify -> Repair). I don't know if you are experiencing the same issue, or the different flavor of the same issue, but when I wanted to test if I could reproduce your issue, I realized that I couldn't launch an application with a debugger attached. MSVSMON.exe would just fail to start (what's even more bizarre: it would try to use the MSVSMON of VS2010, while I was using VS2012). Installation repair fixed that problem (and, yes, I can see the values of all variables perfectly fine). – Algirdas Preidžius Mar 21 '16 at 00:30
  • @AlgirdasPreidžius thanks for the suggestion. I had a clean install of 2015, and just repaired 2008 with no change. This is all running on a VM which I guess could be part of the problem. – geographika Mar 21 '16 at 08:58
  • 1
    If you see 0xbaadfood back in the debug view then "it must be a bug in the debugger" is not the first thing you consider. VS2008 and VS2015 also use *very* different debugging engines. Heap corruption is a very common bug and has very random behavior, it is not guaranteed to cause program failure. – Hans Passant Mar 21 '16 at 09:25
  • @HansPassant - my first thought is that I am missing some VS setting to enable 64bit debugging. Second that there is some issue with the code. Re the "0xbaadfood" value in the screenshots - these are correct in that no value is set for the "fontset" property. However the "name" property is set - and displays in the 32 bit version. – geographika Mar 21 '16 at 10:30

1 Answers1

0

The above was caused by stdrup being deprecated on Windows, and the heap becoming corrupted.

The MapServer issue on GitHub can be seen at https://github.com/mapserver/mapserver/pull/5277

This question also describes a similar issue: Heap corruption with strdup

Community
  • 1
  • 1
geographika
  • 6,458
  • 4
  • 38
  • 56