piston
piston copied to clipboard
Issue with setting run_memory_limit for code execution
I am unable to understand why i need to provide a run_memory_limit of as large as 10GB for a java program that just reverses a string. Not getting this issue with python3, python2 for node also i have to provide atleast 330 MB. Java Payload 1 which does not work -
{ "language": "java", "version": "15.0.2", "files": [ { "name": "test.java", "content": "public class Main {\n public static void main(String[] args) {\n String value1 = args[0];\n\n char[] try1 = value1.toCharArray();\n \n for (int i = try1.length - 1; i >= 0; i--)\n System.out.print(try1[i]);\n }\n}\n" } ], "args": [ "reverse me :)" ], "run_memory_limit": 1000000000 }

Java Payload 2 which works by adding one more zero to run_memory_limit -
{ "language": "java", "version": "15.0.2", "files": [ { "name": "test.java", "content": "public class Main {\n public static void main(String[] args) {\n String value1 = args[0];\n\n char[] try1 = value1.toCharArray();\n \n for (int i = try1.length - 1; i >= 0; i--)\n System.out.print(try1[i]);\n }\n}\n" } ], "args": [ "reverse me :)" ], "run_memory_limit": 10000000000 }

I want to limit the memory at run time so i cannot avoid this parameter also. Any help would be much appreciated
I think we might have an issue with memory limiting using ulimit, I will investigate this further
i think we have to limit with --memlock instead of --as for memory limits.
I am also facing the same issue with charrp.dotnet.
I am unable to understand why i need to provide a compile_memory_limit of as large as 25GB for a csharp.dotnet program that just reverses a string. Not getting this issue with python3, python2 for node also i have to provide at least 330 MB.
{ "language": "csharp.net", "version": "5.0.201", "files": [ { "name": "test.cs", "content": "using System;\n\npublic class MainClass\n{\n public static string Reverse(string a)\n {\n char[] charArray = a.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n \n public static void Main(string[] args)\n {\n Console.WriteLine(Reverse(\"ba\"));\n }\n}\n" } ], "run_timeout": 3000, "compile_memory_limit": 25000000000 }
Is there any update? or any place in code where I can look into, try to fix and contribute?