fix(deepin-os-release): Filter out RDRAND hardware random warnings to ensure clean output#560
fix(deepin-os-release): Filter out RDRAND hardware random warnings to ensure clean output#560gitee-zeqi wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gitee-zeqi The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @gitee-zeqi. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
TAG Bot New tag: 6.7.41 |
|
TAG Bot New tag: 6.7.42 |
|
这是为了不影响deepin-os-version的输出? |
|
“WARNING: CPU random generator seem to be failing, disabling hardware random number generation” 这些是输出到 stderr的吧,deepin-os-version应该是输出stdout(忘记是不是了),如果它俩不是真的混到同一个管道的,应该也不是问题。 |
There was a problem hiding this comment.
Pull request overview
This PR updates the deepin-os-release tool to suppress specific recurring RDRAND-related WARNING lines emitted to stderr, preventing them from corrupting version-detection output consumed by downstream tooling (e.g., CMake).
Changes:
- Redirects
stderrto a pipe and forwards it through aQThreadthat filters out two known WARNING patterns. - Restores the original
stderrat program shutdown and waits for the filter thread to finish.
Comments suppressed due to low confidence (2)
tools/deepin-os-release/main.cpp:69
- The return values of
dup,pipe, anddup2aren't checked. If any of these fail, stderr may be left in an undefined state (or redirected without a working reader), potentially hanging the process. Add error handling/fallback (e.g., skip filtering when setup fails and ensure fds are closed/restored).
// 设置过滤器
int origStderr = dup(STDERR_FILENO);
int pipefd[2];
pipe(pipefd);
dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]);
tools/deepin-os-release/main.cpp:175
- Cleanup order is racy:
close(origStderr)happens beforefilterThread->wait(), but the filter thread may still be forwarding stderr lines usingm_origStderr. This can cause EBADF and lost stderr output. KeeporigStderropen until after the thread finishes (or dup the fd for the thread and let the thread own/close it).
// 清理
dup2(origStderr, STDERR_FILENO); // 恢复 stderr
close(origStderr);
filterThread->wait();
delete filterThread;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
对,不影响deepin-os-version的输出和cmake编译(抱歉,因本人还是学生现在才回) |
会影响到调用deepin-os-version的cmake项目编译,cmake会报错,错误如下: flags.make里面被污染的地方如下: 正常这里没有警告,但是不知为什么cmake把警告也一起合并进来了,所以要过滤,调用修改后的deepin-os-version就没有这些警告污染了,而且也能过编译了,证明问题就在这 |
… ensure clean output This fix adds a pipe-based stderr filter using QThread, precisely discarding the known RDRAND warning lines while preserving all other stderr messages.
…ling - Filter out known RDRAND-related WARNING lines from stderr to prevent pollution of stdout when stdout and stderr are merged by CMake. - Add missing <cstdlib> header for free(). - Close pipe file descriptor when fdopen fails to avoid potential deadlock. - Wrap write() in a retry loop to handle EINTR and short writes. - Update SPDX copyright year to 2026.
在某些平台,CPU 的硬件随机数指令 RDRAND 持续返回异常值。这导致某些第三方加密库在动态库初始化阶段检测到失败,并向 stderr 输出固定的 WARNING 文本:
这样会影响到一些项目的cmake编译,如下:
在终端的输出,修改前:
修改后:
解决方法:
添加一个基于管道 + QThread 的 stderr 过滤器,过滤掉警告