【发布时间】:2019-11-24 16:40:47
【问题描述】:
我第一次在一个小型项目上运行 cpack,其中包含 2 个组件——3 个已编译的可执行文件,生成 debian 包。打包没有完成(我让它运行的最长时间是 30 分钟),它保持在 100% 的 CPU,但不会增加 RAM 使用率。
使用 gdb 附加到 cpack 显示它始终位于 cmSystemCools::CollapseCombinedPath 和一些字符串操作中。我再次运行valgrind --tool=callgrind并安装了调试符号,这是按包含时间排序的:
我怀疑代码中的一些循环,因为 CollapseCombinedPath 在大约 30 秒的(仪表化)执行中被调用了 280 万次,SplitPath 被调用了 570 万次(!!)。
我是 ATM 无法隔离 MWE,但我在 cmake 2.13 和 2.10 中都看到了这种行为(2.10 是上图的来源)。
在cmSystemTools::CollapseCombinedPath 中使用断点单步执行代码时,我看到了:
(gdb) break cmSystemTools::CollapseCombinedPath
Breakpoint 1 at 0x55a6f02460a0: file ./Source/cmSystemTools.cxx, line 1371.
(gdb) c
Continuing.
Breakpoint 1, cmSystemTools::CollapseCombinedPath (dir="/..", file="..") at ./Source/cmSystemTools.cxx:1371
1371 in ./Source/cmSystemTools.cxx
(gdb) c
Continuing.
Breakpoint 1, cmSystemTools::CollapseCombinedPath (dir="/", file="..") at ./Source/cmSystemTools.cxx:1371
1371 in ./Source/cmSystemTools.cxx
(gdb) c
Continuing.
Breakpoint 1, cmSystemTools::CollapseCombinedPath (dir="/..", file="..") at ./Source/cmSystemTools.cxx:1371
1371 in ./Source/cmSystemTools.cxx
(gdb) c
Continuing.
Breakpoint 1, cmSystemTools::CollapseCombinedPath (dir="/", file="..") at ./Source/cmSystemTools.cxx:1371
1371 in ./Source/cmSystemTools.cxx
(gdb) c
Continuing.
Breakpoint 1, cmSystemTools::CollapseCombinedPath (dir="/..", file="..") at ./Source/cmSystemTools.cxx:1371
1371 in ./Source/cmSystemTools.cxx
(gdb) c
Continuing.
从堆栈跟踪中,代码是从我看到的cmCPackDebGenerator.cxx 调用的
for (std::string currentPath : PackageFiles) {
while (currentPath != WorkDir) {
// the last one IS WorkDir, but we do not want this one:
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
// should not add XXX/application
orderedFiles.insert(currentPath);
currentPath = cmSystemTools::CollapseCombinedPath(currentPath, "..");
}
}
所以代码卡在那里。可能是我的输入有误(我必须检查一下),但 cpack 在这种情况下绝对不应该挂起。
有人可以帮忙吗?稍后我会尝试挖掘更多。
【问题讨论】:
标签: infinite-loop deb cpack