Re: memory instruction reference can't be read
I comment out each statement step by step to find which statement exists
error in release configuration. I find in the following function:
void VSocket::SendControlMessage(int nType,char *pAddress)
{
int n;
unsigned char data[500];
// Type of control packet
data[0] = (unsigned char)nType;
// Length of hostname
n = strlen(m_szLocalName);
data[1] = (unsigned char)n;
// Name of the sender host
memcpy(&data[2], m_szLocalName, n);
if(pAddress == NULL) {
SendTo(data, n+2, PORT_CONTROL, s_szRemoteAddress);
}
else {
SendTo(data, n+2, PORT_CONTROL, pAddress);
}
}
When the above function is called, the error "Unhandled exception in
StreamServer.exe:0xC0000005: Access Violation" will happen. If I comment out
the
// data[0] = (unsigned char)nType;
, the error is gone.
I think that this assignment is legal. In debug configuration, there isn't
any error. Why??
"Scott McPhillips [MVP]" wrote:
mmlab_js wrote:
Hi,
Compiler:Visual C++ 6.0
In debug configuration, I can build the project and run it without error.
But in release configuration, I can build the project and run it.
When I click one button, the compiler shows:
"The instruction at "0x004022ff" referenced memory at "0x00000030". The
memory could not be read." What shall I do to solve this problem?
Thank you.
Turn on debug information in the release build, then run it in the
debugger. When the error occurs use the stack window to find the point
in your code that led to the problem. It looks like an uninitialized
pointer.
--
Scott McPhillips [VC++ MVP]