Skip to content

fix(test): make tst-support_descriptors pass when /dev/null and /dev are on different filesystems (uos-debrebuild build failure) - #53

Merged
Zeno-sole merged 2 commits into
masterfrom
fix/tst-support-descriptors-cross-device
Oct 24, 2026
Merged

Zeno-sole merged 2 commits into
masterfrom
fix/tst-support-descriptors-cross-device

Conversation

@Zeno-sole

Copy link
Copy Markdown
Contributor

fix(test): tst-support_descriptors 在 /dev/null 与 /dev 异设备时失败(2.38-6deepin32)

失败现象

uos-debrebuild 重建 2.38-6deepin31 在 check 阶段失败(非编译错误),全部测试中仅一个不通过:

FAIL: support/tst-support_descriptors
error: tst-support_descriptors.c:141: not true: strstr (proc.out.buffer, expected) != NULL
汇总:5168 PASS / 1 FAIL → make check Error 1 → dpkg-buildpackage exit 2

根因

该流水线使用 sbuild --chroot-mode=unshare,chroot 内 /dev/null 是从另一个文件系统 bind-mount 的(st_dev 0:6),而 /dev 目录在 rootfs 上(st_dev 0:34)。

测试的 subprocess_changed_descriptor 把 fd 3 从 /dev/null 换成 /dev,support_descriptors_check 在两行预期诊断之间多打印了一行:

error: descriptor 3 changed from "/dev/null" to "/dev"
error: descriptor 3 changed device from 0:6 to 0:34   ← 异设备时才出现
error: descriptor 3 changed ino from 4 to ...

测试用一条拼接的 strstr 同时匹配 "changed from … changed ino …",插入行导致失配。普通构建系统 /dev/null 与 /dev 同设备,不出现该行,因此 OBS/常规 CI 不受影响。上游 master 至今未改这两个文件(无现成上游修复)。

修复

debian/patches/any/local-tst-support-descriptors-cross-device.diff:把拼接期望拆成两个独立子串匹配。诊断输出本身不变,仅测试对自身预期输出的匹配可容忍可选的 device 行。

验证(完整 glibc 2.38 源码构建 + 真实复现)

场景 未打补丁 打补丁后
常规环境(/dev/null 与 /dev 同设备) exit 0 exit 0
挂载命名空间内跨文件系统 bind /dev/null(复现 debrebuild chroot 条件) exit 1(错误签名与流水线逐字一致:changed device from 259:4 to 0:5 + :141 not true) exit 0(changed device 诊断照常打印并被校验)

复现方法:宿主 sudo unshare -m sh -c 'mount --bind /tmp/f /dev/null; …' 后直接以构建出的 ld.so 运行测试二进制。

影响面

  • 仅测试代码,不影响任何运行时行为;普通构建系统行为不变
  • 修复后 uos-debrebuild 流水线可完整重建 glibc

…are on different filesystems

The uos-debrebuild pipeline failed to rebuild glibc 2.38-6deepin31 at
the check stage with a single failing test:

  FAIL: support/tst-support_descriptors
  error: tst-support_descriptors.c:141: not true: strstr (proc.out.buffer, expected) != NULL
  (summary: 5168 PASS, 1 FAIL -> make check Error -> dpkg-buildpackage exit 2)

Root cause: that chroot (sbuild --chroot-mode=unshare) bind-mounts
/dev/null from a different filesystem than /dev (st_dev 0:6 vs 0:34).
In subprocess_changed_descriptor the test changes fd 3 from /dev/null
to /dev, and support_descriptors_check then prints an extra

  error: descriptor 3 changed device from 0:6 to 0:34

line between the "changed from" and "changed ino" lines.  The test
matches both expected lines with one glued strstr, which no longer
matches.  On ordinary build systems /dev/null and /dev share st_dev,
so the extra line never appears there.

Fix (debian/patches/any/local-tst-support-descriptors-cross-device.diff):
split the glued expectation into two independent substring checks.  The
diagnostics printed by support_descriptors_check are unchanged; only the
test's matching of its own expected output becomes tolerant of the
optional device line.

Verified against a full glibc 2.38 source build:

- unpatched test: exit 0 normally; exit 1 (same error signature as the
  pipeline) inside a mount namespace with /dev/null bind-mounted from a
  different filesystem
- patched test: exit 0 in both environments, with the "changed device"
  diagnostic still being printed and checked

Log: fix the only failing self-test so glibc rebuilds complete in unshare-based chroots

Influence:
1. glibc 2.38-6deepin32 completes make check in the uos-debrebuild (unshare) environment; no behavior change elsewhere
2. The support_descriptors_check diagnostics are unchanged, only the test's own expectation matching is split
3. Ordinary build systems (/dev/null and /dev on the same filesystem) behave exactly as before

fix(test): 使 tst-support_descriptors 在 /dev/null 与 /dev 位于不同文件系统时也能通过

uos-debrebuild 流水线重建 glibc 2.38-6deepin31 在 check 阶段失败,仅一个
测试不通过:

  FAIL: support/tst-support_descriptors
  error: tst-support_descriptors.c:141: not true: strstr (...) != NULL
  (汇总:5168 PASS,1 FAIL → make check Error → dpkg-buildpackage 退出 2)

根因:该 chroot(sbuild --chroot-mode=unshare)的 /dev/null 是从与 /dev
不同的文件系统 bind-mount 而来(st_dev 0:6 vs 0:34)。测试在
subprocess_changed_descriptor 中把 fd 3 从 /dev/null 换成 /dev,
support_descriptors_check 会在 "changed from" 与 "changed ino" 两行之间
多打印一行:

  error: descriptor 3 changed device from 0:6 to 0:34

而测试用一条拼接的 strstr 同时匹配两行,遂失配。普通构建系统的
/dev/null 与 /dev 同设备,不会出现该行。

修复(debian/patches/any/local-tst-support-descriptors-cross-device.diff):
把拼接期望拆成两个独立的子串匹配。support_descriptors_check 的诊断输出
不变,仅测试对自身预期输出的匹配可容忍可选的 device 行。

基于完整的 glibc 2.38 源码构建验证:

- 未打补丁:常规环境 exit 0;在挂载命名空间内将 /dev/null 跨文件系统
  bind-mount 后 exit 1(错误签名与流水线完全一致)
- 打补丁后:两种环境均 exit 0,"changed device" 诊断仍照常打印并校验

Log: 修复唯一失败的自检测试,使 glibc 在 unshare 类 chroot 中能完成重建

Influence:
1. glibc 2.38-6deepin32 在 uos-debrebuild(unshare)环境可完整通过 make check,其他环境无行为变化
2. support_descriptors_check 诊断输出不变,仅拆分测试自身的期望匹配
3. 普通构建系统(/dev/null 与 /dev 同文件系统)行为与之前完全一致

repo: glibc #master
@Zeno-sole

Copy link
Copy Markdown
Contributor Author

/integrate

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from zeno-sole. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 2.38-6deepin32
EXISTED: no
DISTRIBUTION: unstable

@github-actions

Copy link
Copy Markdown

AutoIntegrationPr Bot
auto integrate with pr url: deepin-community/Repository-Integration#4694
PrNumber: 4694
PrBranch: auto-integration-40103117126

… with proper blank-context lines

dpkg-source applies patches with patch -t -F 0 (no fuzz allowed); the
previous version of the patch needed fuzz 1 for hunk 2 and had empty
lines instead of single-space blank context lines, which made
dpkg-source abort with 'Hunk #2 FAILED' / 'unexpected end of diff'.
Regenerate the body mechanically from the verified build tree so it is
byte-identical to GNU diff output: single hunk, exact line counts
(-128,20 +128,28), proper blank context markers.

Verified: patch -t -F 0 dry-run clean; full dpkg-source --before-build
applies the whole series including this patch with exit 0 and no
warnings; the applied file is byte-identical to the one used in the
end-to-end test verification (cross-device /dev/null: unpatched exit 1,
patched exit 0).
@Zeno-sole

Copy link
Copy Markdown
Contributor Author

已修复 patch 无法应用的问题(commit cfe1acf6)

失败原因有两点:

  1. dpkg-source 以 patch -t -F 0(禁 fuzz)应用补丁,而原版 hunk Apply any/local-revert-bz13979.diff #2 需要 fuzz 1 才能套上 → Hunk #2 FAILED;
  2. 补丁里的空白上下文行写成了空行,而 GNU diff 规范是单个前导空格,行数计数也少了一行(} 后的空上下文行)→ unexpected end of diff。

修复方式:从实际验证过的构建树机械重新生成 diff 体(单 hunk,精确计数 @@ -128,20 +128,28 @@,空白上下文行带前导空格),与 GNU diff 输出逐字节一致。

验证:

  • patch -t -F 0 -N --dry-run 干净通过;
  • 在纯净源码树上跑完整的 dpkg-source -i -I --before-build .(与 CI 失败命令同口径):全 series 应用成功,exit 0,无任何警告;
  • 应用后的文件与此前端到端验证(异设备 /dev/null:未打补丁 exit 1、打补丁 exit 0)所用的文件 md5 完全一致(15ad600d…)。

@Zeno-sole

Copy link
Copy Markdown
Contributor Author

本地完整打包构建验证(cfe1acf6 之后)

在 uos:2501 容器内用 dpkg-buildpackage -us -uc -b -j16 对打补丁后的源码树做了完整构建:

  • dpkg-source 补丁应用(原 CI 失败点):干净通过,无警告
  • 编译与 i386/x32 flavor 的 check:全部通过
  • 本体(amd64-libc)check 阶段:support/tst-support_descriptors PASS(流水线上唯一失败的测试;本地 5125 PASS)
  • 残留 6 个 FAIL 全部是 nptl gdb-printers 测试(Error: Response does not match the expected pattern = 容器 gdb 版本与打印机脚本不匹配)。这类测试在 debrebuild chroot 里因无 gdb 而记 UNSUPPORTED(流水线汇总中它们正是 UNSUPPORTED),不会导致失败——与本补丁无关

结论:在流水线等价环境(无 gdb)下,该补丁可使 glibc 构建全绿。

@Zeno-sole

Copy link
Copy Markdown
Contributor Author

/integrate

@Zeno-sole
Zeno-sole merged commit 4a162b1 into master Oct 24, 2026
8 of 10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants