AC500 Runtime error #81 (Access violation task = new task)
Hello i am testing my program on the PM592 and I frequently get runtime error #81 (Access violation task = new task) and the PLC goes to stop state.The Control builder tells :
E2: IEC task 0 'Index of the faulty IEC task, Task index = x - 4. Comp 9, Dev 0 , Mod 4, Ch 2, Err 38, Error number 0151003302.
All i know is because of the following code - i get this error, which if i do not use there is no such problem. This code helps me to store the LREAL data into the array aDataOut[1..10].There is only one task in the program which is configured as cyclic task with 100 ms. (but with freewheeling also the result is the same)
Please refer to the declaration and the code below.
(*This is declaration of varables*)
aData_Out: ARRAY[1..10] OF LREAL;
Y_Out: POINTER TO LREAL;
xAssign: BOOL := FALSE;
(*This is the code - causing the issue*)
IF NOT xAssign THEN
xAssign:=TRUE;
Y_Out := Signal_Output.Y;
FOR i :=1 TO 10 BY 1 DO
aData_Out[i] := Y_OUT^;
Y_Out := Y_Out +8; (*increment of 8 bytes means i want to read the next lreal data*)
END_FOR;
END_IF;
I am also making sure to call this for-loop only once (using bool xAssign) in the runtime.
Sorry i cannot attach the test program as it contains some yet to be released stuff .
regards,
Rahul Singh
Voted best answer
brought comments here in answer arear to give more visibility to on going interactions in questions comment section.
by GustavA Rank: 79 on 1/26/2015 5:07:20 AM | Like (0) | Report
Hello!
Can you make a complete test example. i and Signal_Output is not defined.
by josh.donovan Rank: 143 on 2/23/2015 4:17:02 AM | Like (0) | Report
I'm not sure if this will solve the problem but the Codesys Documentation recommends using p:=p+SIZEOF(p^); for incrementing pointers. I know this has helped solve a similar issue for me.
by Rahulsingh.rk Rank: 2175 on 3/8/2015 10:19:18 AM | Like (0) | Report
Hello, Sorry for checking late. The main reason for this problem was related to the memory leaks. The C code app in my project was using the dynamic mem allocation. Which was causing the overusage of heap memory. which resulted to this error. Thanks for the reply GustavA and Josh.
regards,
Rahul
Add new comment