Orca pipeline
12 results today 24 agents on 1 worker Admin

Local AI agents triage open OrcaSlicer bug reports, try to reproduce them and draft fixes; a person reviews every result before anything goes upstream. An independent experiment, read only.

Queue / #17362

#17362New

[Bug] Concurrent race condition when loading multi-object 3MF files on Windows causes empty model parsing (CLI mode)

Agent answer

No agent has taken this issue yet.

Issue text on GitHub

Is this issue reproducible in the latest nightly build?

  • [x] I have checked the latest nightly build and the issue is still reproducible

Is there an existing issue for this problem?

  • [x] I have searched the existing issues

OrcaSlicer Version

2.5.0

Regression compared to a previous version

No response

Operating System (OS)

Windows

OS Version

Windows11

Additional system information

CPU:intel Core i5-6500
Memory:16GB

Printer

Voron2.4 350

How to reproduce

Steps to reproduce:

  1. Prepare a multi-object 3MF file (e.g., a project-type 3MF containing multiple parts, project configs, or thumbnails in the Metadata/ folder).
  2. Open a command line interface (CLI).
  3. Run the command: orca-slicer.exe <path_to_your_multi_object.3mf> (or using the standalone libslic3r CLI).
  4. Observe the CLI output. The engine will immediately skip the model and throw the error: [Warning] Skipping unloadable model: ... (The supplied file couldn't be read because it's empty.)
  5. (Optional) Move the same 3MF file to a simple path like C:\test\whistle.3mf to verify that this is not a path issue. The error still occurs.

(Note: This issue is highly reproducible in headless/CLI mode due to multithreading. In GUI mode, the loading timing might hide the race condition.)

Actual results

Actual results:

The CLI fails to parse the model and skips it entirely. It outputs the following warning and error log to the console, and no G-code is generated:

[Warning] Skipping unloadable model: D:\path\to\model.3mf (The supplied file couldn't be read because it's empty.)

What is happening under the hood:
Because of the multithreaded unpacking of the 3MF objects, the race condition triggers a silent exception during the directory creation (boost::filesystem::create_directories). The exception aborts the model loading process, resulting in an empty geometry/model object being returned to the CLI. Therefore, the CLI interprets the 3MF as "empty" and skips it.

(Note for screenshot: If possible, I will attach a screenshot of my terminal showing the exact [Warning] output when running the CLI command.)

Expected results

Expected results:

The CLI should successfully load and parse the multi-object 3MF file.

Specifically, the following should happen:

  1. The engine's multi-threaded unpacking process should safely handle concurrent directory creation (tolerating ERROR_ALREADY_EXISTS or ERROR_ACCESS_DENIED without throwing unhandled exceptions).
  2. The model geometry and all internal objects should be fully imported.
  3. The CLI should proceed to generate the expected output (e.g., G-code) or at least successfully load the model without throwing the The supplied file couldn't be read because it's empty. warning.

Project file & Debug log uploads

https://makerworld.bblmw.cn/makerworld/model/CNc8e8c535a44e04/53602776/instance/3171e497-9de7-4ef3-9689-508ede146030.3mf?at=1794075203&exp=1794075503&key=baeb4525c79ba85d87b0992aad7535e6&uid=735061059&version=v1

Checklist of files to include

  • [x] Log file
  • [x] Project file

Anything else?

In DeepSeek Harness:

诊断完成。给你完整结论。

三个问题的真实答案

1. 为什么会报错(跟中文路径无关!)

我做了决定性实验:把同一个 3MF 复制到纯英文路径 whistle.3mf,照样失败。

[警告] 跳过无法装载的模型: ...\tmp\whistle.3mf  (The supplied file couldn't be read because it's empty.)

真正原因:这是「备份/恢复型 3MF」,引擎要多线程解包

你这个 3MF 的结构:

3D/3dmodel.model
3D/Objects/object_1.model        ← 分件存储
Metadata/pick_1.png              ← 缩略图
Metadata/project_settings.config ← 项目配置
Metadata/slice_info.config       ← 切片信息

引擎(Model.cpp:1105)会为它建临时备份目录:

buf << "/orcaslicer_model/" << std::put_time(now_time, "%a_%b_%d/%H_%M_%S#");
backup_path = parent_path.string() + buf.str();
if (!exists(temp_path)) {
    create_directories(backup_path + "/3D/Objects");   // ← 这里
    create_directories(backup_path + "/Metadata");
}

exists() 检查与 create_directories() 之间有竞态:3MF 的多个对象是并行解包的,两个线程同时通过 exists() 检查(都返回 false),然后都去创建 —— Windows 上第二个 mkdir 返回 ERROR_ACCESS_DENIED(5) 而不是 ERROR_ALREADY_EXISTS(183),于是抛异常。

后果链:备份目录建失败 → _load_model_from_file 中途放弃 → 对象被跳过 → The supplied file couldn't be read because it's empty。


2. 我已经修好了一半

问题 状态
中文路径打不开 ✅ 已修复(见下)
备份目录并发竞态 🔴 这是引擎 bug,需改库源码

中文路径的修复(已验证生效)

新增 platform_encoding.cpp:

// Windows argv 是 ANSI(GBK),libslic3r 内部按 UTF-8 解释路径
std::vector<std::string> argv_u8_storage = kelvix::argv_to_utf8(argc, argv);
// ANSI -> UTF-16 -> UTF-8,之后全程 UTF-8

证据:修复前报 Unable to open the file D:\下载\...,修复后能打开文件了(不再报 "Unable to open",而是卡在备份目录)。

你之前看到的 璺宠繃鏃犳硶瑁呰浇... 乱码也修了 —— 那是 UTF-8 被当 GBK 显示。


3. 「路径需要加引号也能识别」

这个已经有了,但实现方式是标准的:

# 带引号(你试过的)
.\libslic3r.exe -model "D:\下载\带 空格 的文件.3mf"

# 不带引号(无空格时)
.\libslic3r.exe -model D:\models\a.3mf

Windows 的 argv 由 CRT 自动处理引号,引号只是 shell 层面的分组符,传进来时已经被剥掉了。所以加不加引号都能识别 —— 你的测试里加引号失败不是引号的问题,是备份目录的问题。


现在必须做的决定

引擎那个并发 bug 在 Model.cpp:1105-1145,要修必须改库源码。

方案 说明 违反纪律?
A. 改库源码(补锁/容忍 EEXIST) 约 10 行,改成 create_directories(ec) 忽略 already_exists ❌ 违反「不改库源码」
B. CLI 层串行化 无法做 —— 竞态在引擎内部多线程里 —
C. 预先建整个目录树 引擎用时间戳做目录名,CLI 猜不到 ❌ 不可行
D. 把 TMP 指到别处 不解决竞态,只换位置 ❌ 无用

唯一可行的是 A —— 这是个真实的引擎缺陷,不是我们的用法问题。


我的建议

这属于「必须修的第三方 bug」,我建议作为补丁 E 登记:

// Model.cpp:1129-1142 改为
boost::system::error_code ec;
boost::filesystem::create_directories(backup_path + "/3D/Objects", ec);
if (ec && ec != boost::system::errc::make_error_code(boost::system::errc::file_exists))
    BOOST_LOG_TRIVIAL(error) << "..." << ec.message();
// 同样处理 /Metadata

影响面:只改 Model.cpp 一个函数,约 8 行。需重新编译库(~40 分钟)。

要我做吗? 还是你接受「3MF 备份型文件暂不支持,只用 STL」?


我在使用此仓库的v2.5.0-rc分支源码进行libslic3r CLI构建时出现了此类问题,以上文本为AI的参考信息,我的邮箱是[email protected],我的项目仓库位于https://cnb.cool/LDKJ.ONLINE/KelvIX-Studio

Author
lingdu-k2
Comments
3
Created
2026-11-07
bug

Log

  1. Collected from GitHub
    panel · 3 h ago