Closed DrDonut21 closed 3 years ago
Okay, I did a bit more digging around:
Hi! Thanks for your report.
The problem is that the stack size in TwinCAT 3 is fixed to 60KB. Creating such a huge array in the method fills almost the entire stack.
I simply moved the testArray to the body of the function block instead:
FUNCTION_BLOCK FB_CompVSType09_Test EXTENDS TcUnit.FB_TestSuite
VAR
testArray : ARRAY [0..50312] OF BYTE;
END_VAR
Then try to pass a reference to that array to your methods instead, such as:
M_CheckPointers_NoLvInterlock(testArray);
I tested this on my machine and it worked fine.
Edit. It is actually possible to change the stack size since TwinCAT 4024, if that is what you are using. See @Roald87 answer in the linked StackOverflow discussion further down.
This huge array was actually because it crashed when we just used a bunch of variables. But I think your suggestion of just putting them in the function block may actually be better.
Thank you for this! I will close the ticket now. The actual crashing of the machine is more of a Beckhoff problem than a TcUnit problem I think...
I'm happy you managed to sort it out!
It seems that a stack overflow in the code of a unit test can crash the system. Reproduction steps:
If you do not check the 'autostart boot project' box, you can click 'login'. It will now tell you that the Port_851 application does not exist. If you install that, and click run (F5), it will display an error of a stack overflow.
The attached file contains a project with this behavior. My system: Windows 10 Enterprise LTSC, 64 bit. Installed Memory 4,00 GB TwinCAT version 3.1.4024.7 TcUnit version 1.1.0.0 Please not that this is a virtual machine (using VmWare).
TcUnitTest.zip
If you need any other information, or if there is anything I can do to prevent this behavior, please let me know. I don't know if this is a TcUnit issue, or a TwinCAT issue, so I will try to contact Beckhoff as well...