Skip to content

Avoid allocating in pre_exec closure#1

Closed
yuki0iq wants to merge 1 commit intoproxmox:masterfrom
yuki0iq:pre_exec
Closed

Avoid allocating in pre_exec closure#1
yuki0iq wants to merge 1 commit intoproxmox:masterfrom
yuki0iq:pre_exec

Conversation

@yuki0iq
Copy link
Contributor

@yuki0iq yuki0iq commented Nov 21, 2025

Error::new allocates memory (see rust-lang/rust#148971). This is bad in multi-threaded programs, which dap-gui 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.

@Fabian-Gruenbichler
Copy link
Contributor

hi! thanks for your PR. this repository is a read-only mirror - would you be willing to send this as a patch with Signed-off-by to pbs-devel@lists.proxmox.com ? see https://pve.proxmox.com/wiki/Developer_Documentation for details :)

@yuki0iq
Copy link
Contributor Author

yuki0iq commented Dec 5, 2025

yeah, I now sent a patch to the list. thank you for redirecting and have a nice day

@Fabian-Gruenbichler
Copy link
Contributor

thanks a lot!

@Fabian-Gruenbichler
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants