You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
We currently do not validate against passing parameters to function blocks outside of the intended variable blocks.
Given we define a function block without input parameters:
FUNCTION_BLOCK FOO
VAR
val : STRING[65536];
END_VAR
END_FUNCTION_BLOCK
If we then try to pass in a parameter regardless, like so:
FUNCTION main : DINT
VAR
str: STRING[65536];
fb: FOO;
END_VAR
fb(str);
END_FUNCTION
Then we either compile without error (for small enough parameters) or the kernel terminates compilation (large aggregate params) and the console prints Killed.
To Reproduce
Copy the above example in a file and then try to compile with plc file.st
Expected behavior
Aborting compilation with a diagnostic rather than the kernel killing the process.
Additional context
Generating IR for this example will fail in the verify stage:
error[E071]: /tmp/.tmpdVP6Xf/target/demo.st.ll:19:13: error: invalid forward reference to function 'FOO' with wrong type: expected 'void (%FOO*)*' but was 'void (%FOO*, [65537 x i8])*'
call void @FOO(%FOO* %fb, [65537 x i8] %load_str)
^
Querying the kernel with dmesg -T| grep -E -i -B100 'killed process':
mhasel
changed the title
Passing a large aggregate variable to a VAR block in a FUNCTION_BLOCK results in termination of the proccess by the kernel
Passing parameters to VAR blocks in stateful POUs is not validated and can result in termination of the proccess by the kernel
Apr 15, 2024
mhasel
changed the title
Passing parameters to VAR blocks in stateful POUs is not validated and can result in termination of the proccess by the kernel
Passing parameters to VAR blocks in stateful POUs is not validated and can result in termination of the process by the kernel
Apr 18, 2024
Describe the bug
We currently do not validate against passing parameters to function blocks outside of the intended variable blocks.
Given we define a function block without input parameters:
If we then try to pass in a parameter regardless, like so:
Then we either compile without error (for small enough parameters) or the kernel terminates compilation (large aggregate params) and the console prints
Killed
.To Reproduce
Copy the above example in a file and then try to compile with
plc file.st
Expected behavior
Aborting compilation with a diagnostic rather than the kernel killing the process.
Additional context
Generating IR for this example will fail in the verify stage:
Querying the kernel with
dmesg -T| grep -E -i -B100 'killed process'
:Tested in WSL and native Ubuntu
The text was updated successfully, but these errors were encountered: