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':
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