refactor: real_fn! macro + fix PTS fd leak (#35)#39
Merged
Conversation
#32 #34 #36) - #31: Replace incorrect u32[32] fd_set casts with libc::FD_ISSET/FD_SET (correct u64[16] on aarch64). Add fd >= FD_SETSIZE bounds check. - #32: Fix poll(timeout=-1) infinite busy-loop. IoWait stores deadline, yield_for_io accepts timeout, wake_io_ready expires timed-out coroutines. - #34: vdiag! macro now gated by VPROC_DIAG env var (AtomicBool). Zero write() syscalls when unset. - #36: Replace 1000×10ms usleep spin-lock in JNI createSubprocess with pthread_cond_timedwait (500ms deadline). 31/31 APK tests pass, hermux round-trip 1028→1017ms. Bahtya
Replace 78 manual std::mem::transmute(real("sym\0")) call sites with a
real_fn! macro that centralizes dlsym resolution and adds debug_assert
null checks. Also fix Vfd::Real fd leak in remove_table_and_get_fds
that caused stress test failures (PTS slave fd was never closed).
Bahtya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
std::mem::transmute(real("sym\0"))call sites with areal_fn!macro that centralizes dlsym resolution and addsdebug_assert!null checksVfd::Realfd leak inremove_table_and_get_fds()— PTS slave fd was never closed, causingstress: 20 rapid bash sessionsto fail at iteration 4 (PTY exhaustion)Changes
src/preload.rs—real_fn!macroreal_fn!("sym\0", Type)macro: callsreal(),debug_assert!null check,transmuteto target typereal_close(fd)kept with updated internalssrc/vfd.rs— PTS fd leak fixremove_table_and_get_fds()now also collectsVfd::Realfds (e.g. PTY slave on fd 0/1/2)ptsfd)Vfd::Filefds, causing 1 fd leak per hermux sessionTest results
stress: 20 rapid bash sessionsnow passes)Closes #35
Bahtya