From: Yuki Sireneva <yuki.utk8g@gmail.com>
To: pbs-devel@lists.proxmox.com
Cc: Yuki Sireneva <yuki.utk8g@gmail.com>
Subject: [pbs-devel] [PATCH pve-xtermjs] Avoid allocating in `pre_exec` closure
Date: Fri, 5 Dec 2025 12:47:50 +0000 [thread overview]
Message-ID: <20251205124802.334198-1-yuki.utk8g@gmail.com> (raw)
`Error::new` allocates memory (see [148971]). This is bad in
multi-threaded programs, which pve-xtermjs AFAIK is. If the fork occurs
while the allocator lock is held by another thread, deadlocks can occur,
since there's no one left in the new process to unlock the mutex.
I do not believe this is UB, and modern libc offer protections against
this issue, but this isn't POSIX-compliant and should preferably be
avoided.
`nix` provides a non-allocating `impl From<Errno> for std::io::Error`,
which can be used instead. This ensures that the correct error code is
forwarded to the parent process, instead of the default `-EINVAL`.
[rust#148971]: https://github.com/rust-lang/rust/pull/148971
Signed-off-by: Yuki Sireneva <yuki.utk8g@gmail.com>
---
termproxy/src/main.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/termproxy/src/main.rs b/termproxy/src/main.rs
index 135468d..31f5a41 100644
--- a/termproxy/src/main.rs
+++ b/termproxy/src/main.rs
@@ -287,7 +287,7 @@ fn run_pty<'a>(mut full_cmd: impl Iterator<Item = &'a OsString>) -> Result<Pty>
unsafe {
command.pre_exec(move || {
- make_controlling_terminal(&secondary_name).map_err(Error::other)?;
+ make_controlling_terminal(&secondary_name)?;
Ok(())
});
}
--
2.51.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next reply other threads:[~2025-12-09 6:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 12:47 Yuki Sireneva [this message]
2025-12-09 16:25 ` [pbs-devel] applied: " Thomas Lamprecht
2025-12-09 16:25 ` [pve-devel] applied: [pbs-devel] " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251205124802.334198-1-yuki.utk8g@gmail.com \
--to=yuki.utk8g@gmail.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.