buffer watch issue in vs2012 debug view - by Smallrui

Status : 


Sign in
to vote
ID 786000 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 5/1/2013 8:31:54 AM
Access Restriction Public


void test_vs2012_bug()
	char * buffer = (char *)malloc(16);
	memcpy(buffer, "123456789012", 12);
	memcpy(buffer + 12, "hello", 1);
//	memcpy(buffer + 12, "hello", 2); ok

	// check buffer in debug view

the expect buffer i will see is 123456789012h
bug it show this below

buffer = 0x006013c8  <Invalid characters in string.>
Sign in to post a comment.
Posted by Microsoft on 5/3/2013 at 2:10 PM

What's happening is that the buffer in the debuggee is lacking a null terminator, so the debugger assumes the string keeps going, until it happens to find a null terminator. In the process, it happens to run into a character that cannot be converted into Unicode and so, it fails to display the string.

To fix the problem, you should try one of the following:
- Fix the code in the debuggee to properly null-terminate the buffer
- Add a format specifier to tell the debugger how many characters to look at (e.g. "buffer,12")
- If the buffer is fixed-size, declare it as a char[] array, for example "char buffer[16];" instead of "char* buffer = malloc(16);"

Visual Studio Debugger Team
Posted by Microsoft on 5/1/2013 at 11:21 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 5/1/2013 at 8:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)