engineer-man / piston

A high performance general purpose code execution engine.
https://emkc.org/run
MIT License
1.95k stars 251 forks source link

Csharp returns stderr /piston/packages/mono/6.12.0/bin/mono: not found #686

Closed karastoyanov closed 2 months ago

karastoyanov commented 2 months ago

On a self-hosted env, mono runtime is already installed:

    {
        "language": "mono",
        "language_version": "6.12.0",
        "installed": true
    }

Every time when I send a POST request to execute any C# code I am getting stderr that the binary mono is not found:

POST request

{
  "language": "mono",
  "version": "*",
  "files": [
    {
      "content": "namespace Test { class HelloWorld { static void Main(string[] args) {System.Console.WriteLine(\"Hello World\");}}}"
    }
  ],
  "stdin": "",
  "args": "",
  "compile_timeout": 10000,
  "run_timeout": 3000,
  "compile_memory_limit": -1,
  "run_memory_limit": -1
}

Response

{
    "compile": {
        "signal": null,
        "stdout": "",
        "stderr": "/runtime/bin/csc: 2: exec: /piston/packages/mono/6.12.0/bin/mono: not found\n",
        "code": 127,
        "output": "/runtime/bin/csc: 2: exec: /piston/packages/mono/6.12.0/bin/mono: not found\n",
        "memory": 7552000,
        "message": "Exited with error status 127",
        "status": "RE",
        "cpu_time": 48,
        "wall_time": 78
    },
    "run": {
        "signal": null,
        "stdout": "",
        "stderr": "/runtime/bin/csc: 2: exec: /piston/packages/mono/6.12.0/bin/mono: not found\n",
        "code": 127,
        "output": "/runtime/bin/csc: 2: exec: /piston/packages/mono/6.12.0/bin/mono: not found\n",
        "memory": 7552000,
        "message": "Exited with error status 127",
        "status": "RE",
        "cpu_time": 48,
        "wall_time": 78
    },
    "language": "csharp",
    "version": "6.12.0"
}

Any hints?

Brikaa commented 2 months ago

I will try to check this tomorrow. Can you try a previous version of Piston in case this is a regression?

karastoyanov commented 2 months ago

Yup, I can try tomorrow as well.

I've sent the same request to the public API and it went without any issues.

In case that it matters:

The contents of piston/packages/mono/6.12.0

-rwxr-xr-x 1 alex alex 807 Sep 14 23:05 build.sh
-rw-r--r-- 1 alex alex 340 Sep 14 23:05 compile
-rw-r--r-- 1 alex alex  27 Sep 14 23:05 environment
-rw-r--r-- 1 alex alex 447 Sep 14 23:05 metadata.json
-rw-r--r-- 1 alex alex  32 Sep 14 23:05 run
-rw-r--r-- 1 alex alex 124 Sep 14 23:05 test.cs
-rw-r--r-- 1 alex alex 103 Sep 14 23:05 test.vb

The contents of piston/data/piston/packages/mono/6.12.0/bin

lrwxrwxrwx 1 raya raya    9 Apr 10  2023 mono -> mono-sgen
-rwxr-xr-x 1 raya raya  132 Apr 10  2023 mono-api-html
-rwxr-xr-x 1 raya raya  132 Apr 10  2023 mono-api-info
-rwxr-xr-x 1 raya raya  27M Apr 10  2023 mono-boehm
-rwxr-xr-x 1 raya raya  133 Apr 10  2023 mono-cil-strip
-rwxr-xr-x 1 raya raya  170 Apr 10  2023 mono-configuration-crypto
-rwxr-xr-x 1 raya raya  20M Apr 10  2023 monodis
-rwxr-xr-x 1 raya raya 1.1K Apr 10  2023 monodocer
-rwxr-xr-x 1 raya raya  690 Apr 10  2023 monodocs2html
-rwxr-xr-x 1 raya raya   40 Apr 10  2023 monodocs2slashdoc
-rwxr-xr-x 1 raya raya 1.8K Apr 10  2023 mono-find-provides
-rwxr-xr-x 1 raya raya 4.9K Apr 10  2023 mono-find-requires
-rw-r--r-- 1 raya raya  12K Apr 10  2023 mono-gdb.py
-rwxr-xr-x 1 raya raya  22K Apr 10  2023 mono-hang-watchdog
-rwxr-xr-x 1 raya raya  11K Apr 10  2023 mono-heapviz
-rwxr-xr-x 1 raya raya  129 Apr 10  2023 monolinker
-rwxr-xr-x 1 raya raya  124 Apr 10  2023 monop
-rwxr-xr-x 1 raya raya  124 Apr 10  2023 monop2
-rwxr-xr-x 1 raya raya 1.5K Apr 10  2023 mono-package-runtime
-rwxr-xr-x 1 raya raya 1.4K Apr 10  2023 mono-service
-rwxr-xr-x 1 raya raya 1.4K Apr 10  2023 mono-service2
-rwxr-xr-x 1 raya raya  30M Apr 10  2023 mono-sgen
-rw-r--r-- 1 raya raya  12K Apr 10  2023 mono-sgen-gdb.py
-rwxr-xr-x 1 raya raya  133 Apr 10  2023 mono-shlib-cop
-rwxr-xr-x 1 raya raya  135 Apr 10  2023 mono-symbolicate
-rwxr-xr-x 1 raya raya 4.3K Apr 10  2023 mono-test-install
-rwxr-xr-x 1 raya raya  131 Apr 10  2023 mono-xmltool
karastoyanov commented 2 months ago

@Brikaa I've deployed the previous version and can confirm that the C# and mono runs without any errors. The problem seems to be with the latest release.

Brikaa commented 2 months ago

The problem was that some packages were built such that to expect a /piston/packages directory (--prefix in most build scripts). There was no such directory inside the sandbox since the package directory was mounted as /runtime. I have pushed a fix to #685 that mounts the directory with its actual path.

karastoyanov commented 2 months ago

Thanks for handling the issue!