Answered by:
Stack frame checking

Question
-
I have a 64bit visual c++ project. I create a new thread. It runs correctly if I have RTCs enabled.(Run time checking for stack frames). It still runs when I have RTCs disabled, but the results are different. Is there some sort of memory setting I can change or something?
- Moved by Jack Zhai-MSFTMicrosoft contingent staff Monday, January 11, 2016 5:23 AM
- Edited by John C Hurst Monday, January 11, 2016 1:44 PM
Saturday, January 9, 2016 11:25 PM
Answers
-
Ok. I figured out what the problem was. I didn't initialize a variable in a struct. The variable must have been a certain value when I used the RTCs option. So the value was different when I disabled RTCs. Thanks to all for the input.
- Edited by John C Hurst Monday, January 11, 2016 7:42 PM
- Proposed as answer by May Wang - MSFT Friday, January 15, 2016 2:51 AM
- Marked as answer by May Wang - MSFT Monday, January 18, 2016 7:51 AM
Monday, January 11, 2016 5:39 PM
All replies
-
I have a 64bit visual c++ project. I create a new thread. It runs correctly if I have RTCs enabled.(Run time checking for stack frames). It still runs win I have RTCs disabled, but the results are different. Is there some sort of memory setting I can change or something?
Provide a short concrete program that demonstrates the problem. Stating "results are different" is hopelessly bereft of information.
Incidentally, this post is best asked in the C++ forum.
Saturday, January 9, 2016 11:50 PM -
Here is the basic code that I create the thread in:
#include <thread>
static void task1()
{
do stuff
}
//code that starts the thread
{
std::thread t1(task1);
t1.detach();
}
note*
I read somewhere that threads were given 1 megabyte stack size. I know I use more than that. How do I change the stack size for this thread?
- Edited by John C Hurst Sunday, January 10, 2016 4:45 PM
Sunday, January 10, 2016 4:39 PM -
>I read somewhere that threads were given 1 megabyte stack size. I know I use more than that. How do I change the stack size for this thread?
Have a look at this thread:
http://stackoverflow.com/questions/13871763/how-to-set-the-stacksize-with-c11-stdthread
... but perhaps you should re-design your code so that you don't need
such a large stack.Dave
Sunday, January 10, 2016 6:18 PM -
Hi John,
Since your question is about C++. I moved your thread to C++ forum for better support.
Thanks for your understanding.
Best Regards,
Lake Xiao
Monday, January 11, 2016 5:23 AM -
Thank you. Does anybody know about boost? Is it up to date? Their thread process allows for setting the stack size.Monday, January 11, 2016 1:40 PM
-
Thank you. Does anybody know about boost? Is it up to date? Their thread process allows for setting the stack size.
The _beginthreadex function allows for setting the size of the stack. See https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx
- Proposed as answer by May Wang - MSFT Friday, January 15, 2016 2:51 AM
Monday, January 11, 2016 2:41 PM -
Ok. I figured out what the problem was. I didn't initialize a variable in a struct. The variable must have been a certain value when I used the RTCs option. So the value was different when I disabled RTCs. Thanks to all for the input.
- Edited by John C Hurst Monday, January 11, 2016 7:42 PM
- Proposed as answer by May Wang - MSFT Friday, January 15, 2016 2:51 AM
- Marked as answer by May Wang - MSFT Monday, January 18, 2016 7:51 AM
Monday, January 11, 2016 5:39 PM -
Please mark the thread answered.Monday, January 11, 2016 9:49 PM