anomalous strncpy behavior

0 Likes

Problem:

I have a question concerning a error message, BoudsChecker 5.02 issues sometimes on a strcpy call.

Here is the code fragment:

char* pcSource;

char* pcDest;

...

unsigned int length = strlen(pcSource);

pcDest = new char [length 1];

strcpy(pcDest, pcSource);

BoundsChecker complains about the first argument to strcpy:

Invalid argument

strcpy, argument 1, char*:0x02322CF0

This new, strcpy sequence is used 100 to 1000 times during one program execution. It is catched by BoundsChecker about every 2nd to 3rd program execution.

What's going wrong ??? Does it depend on the pointer value ???

Resolution:

We have seen this in rare and unreproducable cases.  Our engineergs think what is happening is along these lines: whenever the end of the allocation falls near the end of a page boundary and the next page is paged out, a function we use to test the validity of memory returns that all of the memory is not 'good' when in fact it is.  If the code is ok, supress this error.

Old KB# 12201
Comment List
Anonymous
Related Discussions
Recommended