6262 - Function uses <constant> bytes of stack
Additional information |
Exceeds /analyze:stacksize<constant> |
Recommended fix |
Consider moving some data to heap |
The stack usage exceeds a preset threshold. The default threshold for this warning is 1 KB for drivers, and 16 KB for user space code.
Even in user-mode, stack space is limited, and failure to commit a page of stack results in an unhandlable exception.
The detection threshold for this warning is adjustable using the /STACKHOGTHRESHOLD switch when invoking PREfast for Drivers. For example:
prefast /STACKHOGTHRESHOLD=1024 cl /Zs test.c
will cause this warning to be generated when PREfast for Drivers detects functions that are using more than 1024 bytes of stack.
If you are using Windows Auto Code Review (OACR), you can specify the /STACKHOGTHRESHOLD option by using the PrefastOptions settings in Oacr.ini file.
Example
The following code example elicits this warning:
char Buffer[123456];
The following code example avoids this warning:
char *Buffer;
Buffer = (char *)malloc(123456);
if (Buffer == NULL) {
return;
}
Warning Details
This warning is rare and accurate. If you encounter this error, consider redesigning the code to reduce stack usage.
Send comments about this topic to Microsoft
Build date: 5/3/2011