-
Notifications
You must be signed in to change notification settings - Fork 121
UOJ Upgrade & Refactor Phase 1 #151
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
base: master
Are you sure you want to change the base?
Conversation
! The judger is not working now and requires further fixes
|
还没看代码,但是原有的C++应该被映射为之前版本编译器的默认版本吧,是C++14还是C++11还是C++98来着,记不太清了。 |
原来的 G++ 是 9.X 版本的,默认不用 |
|
另:关于 judger 相关的代码可以参考一下 renbaoshuo/S2OJ#2 ,我当时记得是没有专门做适配也可以使用的,这两个 PR 里面的 diff 应该很相似,实测在 renbaoshuo/S2OJ#2 中的改动对于社区版上数千道存量题目是没有什么影响的。 |
|
还有就是
这样是否会导致构建的时候更容易出现问题?能不能直接下载现成的 deb 包,或者干脆考虑放弃对 Python 2 的支持(目前市占率很低了吧;cc @billchenchina ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This is a major upgrade and refactoring of the UOJ system, transitioning from Ubuntu 20.04 to 24.04 and introducing a new Judger V2 with enhanced security and language support.
- Core judger system rewritten with new sandbox mechanism based on seccomp + ptrace
- Docker environment upgraded from Ubuntu 20.04 to 24.04 with updated toolchain (GCC 14, OpenJDK 21)
- Extended language support including multiple C/C++ and Java versions
Reviewed Changes
Copilot reviewed 37 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/js/uoj.js | Added support for new C/C++ and Java language versions in CodeMirror |
| web/app/libs/uoj-rand-lib.php | Fixed spelling error in function names from "Avaiable" to "Available" |
| web/app/libs/uoj-judger-lib.php | Updated supported languages list with new C/C++ and Java versions |
| web/app/libs/uoj-html-lib.php | Extended syntax highlighting support for new language versions |
| web/app/libs/uoj-data-lib.php | Enhanced compilation system with new compiler interface |
| web/app/controllers/*.php | Updated function calls to use corrected spelling |
| web/Dockerfile | Upgraded to Ubuntu 24.04 with updated dependencies |
| judger/uoj_judger/run/*.cpp | Complete rewrite of judger system with new sandbox implementation |
| judger/uoj_judger/include/*.h | New header files for secure execution and run utilities |
| judger/uoj_judger/builtin/* | Updated judger and checker implementations |
| docker-compose.yml | Added health checks and updated service dependencies |
Comments suppressed due to low confidence (1)
judger/uoj_judger/run/run_program_sandbox.h:1
- Missing
break;statements after cases 6, 7, and 8, causing fall-through behavior which is likely unintended in this state machine.
#pragma once
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
首先是真没找到合适的 ppa,否则不会采取手动编译这个做法. phase1 的改动设计准则是完全不动原有的数据库结构和存储格式,并且保证原有提交必须几乎都能重测,于是就保留了 Python2. 移除 Python2 计划要 phase2 实施. |
- In Testlib interactor, argv[2] is the `tout` file, a file for writing, not a "to-user" pipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尚未 review 的部分:
- web/app/libs/uoj-data-lib.php
- judger/uoj_judger 下的文件
除此之外,可能考虑在合并 #152 后再合并这个 PR。移除 PHPv8 相关组件以后会减少项目整体的复杂度(特别是构建 PHPv8 时出现的高失败率和长耗时)。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉引入了自己的 clang-format 以后不太好和上游官网版 diff 差异部分?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
引入的原因是因为原本的文件风格太混乱了,甚至出现 tab space 混用,大括号换不换行混用等.
目前的 .clang-format 是用 AI「拟合之前的代码风格,选择与原来最接近的样式」而形成的.
你可以把上游也 clang-format 一下然后来跑 diff.
| <?php | ||
| global $uojSupportedLanguages, $uojMainJudgerWorkPath; | ||
| $uojSupportedLanguages = array('C', 'C++', 'C++11', 'Java8', 'Java11', 'Pascal', 'Python2', 'Python3'); | ||
| $uojSupportedLanguages = array('C89', 'C99', 'C11', 'C17', 'C23', 'C++98', 'C++03', 'C++11', 'C++14', 'C++17', 'C++20', 'C++23', 'C++26', 'Java8', 'Java11', 'Java17', 'Java21', 'Pascal', 'Python2', 'Python3'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原先的存量 C++ 提交是否需要搞个 upgrade_map 来做映射呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
或者参考官网版,做一个显示的 mapping,使得 C++03 在存储时仍为 C++ 而非带有具体版本号的语言代码。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
完全没有必要,首先因为原来的「C++」不对应任何一个现在的 C++ 版本(你没法认为一个「用旧版编译器编译的,支持了部分 C++ 17 特性的 gnu++14」是哪个 C++ 版本),如果强制把原来的 C++ 显示为 C++ XX 或者把数据库里的 C++ 全部 overwrite 成 C++ XX 本身就不对.比方说你可能有重测那些「旧提交」的需求什么的,就可以选择这个兼容的 C++ 语言.
其次是没有后缀的 C++ 在重构后不应该在被作为新提交的语言添加进数据库里了:C++ 被隐藏掉了,你无法通过正常手段创建一个语言为 C++ 的提交了.
同时这个语言的存在本身就是个错误,虽然在评测逻辑里 C++ = C++17,但它本质上和固定标准的 C++17 是「两种语言」,不应该出现「之后的 C++ 17 在数据库里记为 C++」这种迷惑设定.
|
留一下这个评论发布时,这个 PR 中的 Judger 和 S2OJ Judger 的 diff: diff with
|
|
可否将最近的关于「MathJax」和「Prism」的提交暂且撤下?这个 PR 有点过大了,不要再向里面塞其他东西了,不然 review 心智负担会愈来愈大。 |
|
Reverted |
TL;DR:升级 Ubuntu docker image 至 24.04,编译器至软件源中最高版本.并下放部分 UOJ 官网版特性至社区版.
本次更新不破坏原有数据库和存储格式等,理论来讲升级后不会影响原有 OJ 正常工作.
摘要
本次更新是对 UOJ 评测系统的一次大规模重构和现代化升级.核心变更在于引入了全新的 Judger V2,它基于
seccomp和ptrace实现了更安全、更强大的沙箱机制.同时,我们将web和judger的基础镜像从 Ubuntu 20.04 全面升级至 Ubuntu 24.04,并更新了相关的工具链(如 GCC 14, OpenJDK 21),扩展了对 C++ 和 Java 多版本标准的支持.主要变更
1. 核心评测机重构 (Judger V2)
run_program,采用seccomp+ptrace实现沙箱,相比旧版仅依赖ptrace的方式,提供了更强的安全性和更精细的系统调用控制.uoj_judger_v2.h,将原先硬编码在judger.cpp中的评测流程(如处理子任务、打包测试、Hack 等)抽象为更通用、更易于扩展的 C++ 类和函数.这使得为特殊题型编写自定义judger变得更加简单和清晰.run/compile程序,负责处理所有语言的编译任务.Web 后端现在通过调用此程序来编译题目数据(如std,checker),不再直接调用g++等编译器,增强了模块化和可维护性.同时此特性同步官网版类似 language_suffix 的效果.可使用 chk17.cpp、val20.cpp 等名称调用指定版本的编译参数进行编译.score_t类型,评测核心现在原生支持浮点数分数.但为了保证数据库结构兼容性,存储到数据库时整题的分数四舍五入,但每个测试点分数保留实数.testlib.h从0.9.5大幅升级至0.9.44,带来了大量新功能和稳定性修复.2. 环境现代化与 Docker 改进
web和judger的 Docker 镜像均从 Ubuntu 20.04 升级至 24.04.v8js扩展在 GCC 14 下的编译问题.uoj-db和uoj-web服务添加了healthcheck,并使用depends_on.condition确保服务按健康状态顺序启动,解决了启动时可能出现的竞态问题.web容器的启动命令改为apache2ctl -D FOREGROUND,这是在 Docker 中运行 Apache 的标准实践.3. 语言支持扩展
4. 代码质量与修复
.editorconfig和.clang-format文件,以规范化代码风格.yesnochecker 现在可以比较一连串的 "YES" 或 "NO",而不仅仅是单个.judge_client中isAlive()的 Python 3 语法兼容性问题.uojRandAvaiable...系列函数名的拼写错误,统一为uojRandAvailable....