Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error was thrown while running Baltamatica in the go-judge. #134

Open
EbolaEmperor opened this issue Jan 28, 2025 · 7 comments
Open

An error was thrown while running Baltamatica in the go-judge. #134

EbolaEmperor opened this issue Jan 28, 2025 · 7 comments

Comments

@EbolaEmperor
Copy link

Hello, I encountered some trouble while using go-judge and hope to get your assistance!

I attempted to run Baltamatica (a Chinese numerical computation software similar to MATLAB) in the go-judge sandbox environment, but I ran into some issues:

  • First, I installed Baltamatica directly inside the Docker container where go-judge is installed.
  • Then, I ran the container’s bash shell and executed Baltamatica within it, and everything worked fine without any errors.
  • However, when I used a POST request through go-judge to submit a run request, I received the following error:
    terminate called after throwing an instance of 'std::logic_error'
      what():  basic_string::_M_construct null not valid
    

I suspect that the issue might be related to the permission restrictions in the go-judge sandbox environment, which may be preventing Beitai Tianyuan from accessing external files it needs.

您好,我在使用 go-judge 时遇到了一点麻烦,希望能获得您的帮助!

我尝试在 go-judge 沙箱环境里运行北太天元(一个国产数值计算软件,模仿 MATLAB 的一款产品),但出现了一些问题:

  • 首先,我直接在安装了 go-judge 的 docker 容器里安装了北太天元
  • 然后,我运行容器里的 bash,并在里面运行北太天元,没有出现异常
  • 然而,当我使用 POST 的方式通过 go-judge 提交 run 请求时,我收到了这样的报错:
    terminate called after throwing an instance of 'std::logic_error'
      what():  basic_string::_M_construct null not valid
    

我怀疑可能是 go-judge 沙箱环境对权限的限制,导致北太天元试图访问的外部文件无法访问。

@criyle
Copy link
Owner

criyle commented Jan 28, 2025

可以尝试使用 strace 运行检查访问的文件日志,然后调整 mount.yaml配置包含访问过但是沙箱内缺失的文件。

@EbolaEmperor
Copy link
Author

EbolaEmperor commented Jan 29, 2025

谢谢!我已经检查了,并将 /etc, /opt, /var 等等目录全都加进了 mount.yaml 里,并且重新启动了 docker。但还是不行,北太天元的报错信息还是和开始一样。

我写了 c++ 程序访问这些目录,在 go-judge 里可以正常运行。

所以我想会不会是别的什么限制。有没有方法完全取消 go-judge 的限制,让程序和真实系统里直接运行完全一样呢?

@criyle
Copy link
Owner

criyle commented Jan 29, 2025

可以尝试加入 -net 取消联网限制。限制存在的意义就是不能让用户提交的程序访问/修改任意资源,所以不能完全取消。

@syc0000000
Copy link

可以尝试加入 -net 取消联网限制。限制存在的意义就是不能让用户提交的程序访问/修改任意资源,所以不能完全取消。

我遇到同样的问题,两个程序需要通过socket交互,在沙箱环境无法正确发送消息。请问“ -net ”选项应该如何使用,直接加载启动命令中似乎不起作用

@criyle
Copy link
Owner

criyle commented Feb 13, 2025

-net 会使用宿主机的网络栈,可能 socket 并不是使用的 inet ,可能是 unix domain socket。可以尝试使用脚本在同一个容器中同时运行两个程序。

@syc0000000
Copy link

-net 会使用宿主机的网络栈,可能 socket 并不是使用的 inet ,可能是 unix domain socket。可以尝试使用脚本在同一个容器中同时运行两个程序。

目前就是在一个容器内运行两个程序,仍然打不通。go judge主程序是docker启动的,在docker的程序入口加"-net"选项,程序会直接报错退出,提示这是无效的选项,所以想问问正确的操作方式是什么,怎样才能使这个选项生效。
直接attach到go judge容器中运行脚本可以正常通信,但通过沙箱环境运行会出问题。socket可以正常绑定,但无法connect和发送信息。如果信息不够判断问题,今天白天可以补充一些报错。

btw,这个问题应该不属于bug,但文档中确实没有说明网络相关问题,以及想问问默认对系统调用是否有限制?

@criyle
Copy link
Owner

criyle commented Feb 13, 2025

应该是 -net-share 选项使用宿主机网络。或者在容器中修改 mount.yaml 配置文件,反注释最后一行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants