Track the implicit state machines in `src/` and the defects they hide
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- c
調査の方向性
Start by reading the cited lifecycle and defect locations in src/runtime/thread.c, src/runtime/forkipc.c, src/syscall/signal.c, src/core/guest.c, src/syscall/inotify.c, src/syscall/usbdev.c, and src/debug/gdbstub.c. The issue says the survey was not built or run, so verify a cited defect with a focused probe or test before filing it as a separate issue and linking it here. Done means the defects are individually tracked and the proposed lifecycle changes have a defined scope.
索引モデルが issue の本文から書いたものです。
説明
Problem
Most object lifecycles in elfuse have no named state. The state lives in a combination of bools, a sentinel value (-1, 0, NULL), a refcount plus a flag, an atomic changed by CAS, the position inside a protocol, or the X7/X8/X9-X11 registers on the HVC return path. Each transition is a write at its own call site, so nothing checks that a transition is legal from the current state, and a missing or skipped transition shows up only as a bug.
A read of src/ at 0c499d7 found 101 such lifecycles with three or more states, or two states and an ordering rule. Nothing was built or run for this survey; the defects below were found by reading the cited lines.
Only five enums in src/ name a lifecycle, and their transitions are still spread out:
exec_handoff_state_t(src/syscall/exec.c): one setter,exec_handoff_set_state, with no from-state check; a successful exec writes EMPTY twice.urb_state_t(src/syscall/usbdev.c): three flags (discarding,orphaned,handback) carry the rest of the lifecycle, so COMPLETED also covers records IOKit still owns.posix_timer_notification_t(src/syscall/signal.c): written at 6 sites in 5 functions; armed (expiry_ns != 0) and SIGEV_NONE (signum == 0) stay implicit.tlbi_kind_t(src/core/guest.h): a one-way widening accumulator changed in 3 functions.- the anonymous
hist_modeenum (src/debug/syscall-hist.c).
| Area | Count | Examples |
|---|---|---|
Signals, timers, SysV IPC, memory (signal.c, time.c, sysvipc.c, asyncio.c, sys.c, mem.c) |
25 | shared-set signal claims, SROP cookie stack, on_altstack, pending_fault, itimers, shmat table, RLIMIT_CPU sampler, MAP_FIXED replace transaction, brk tracker |
Path and network (path.c, casefold-walk.c, chown-overlay.c, net*.c, netlink.c) |
15 | path_translate_at pipeline, RESOLVE_NO_XDEV walker, chown overlay entry, SCM_RIGHTS install and rollback, abstract AF_UNIX entry, netlink reply buffer and dump framing |
Core (guest.c, shim.S, bootstrap.c, rosetta.c, vdso.c, shim-globals.c) |
11 | W^X page flip (HVC #9), post-HVC X8 protocol, stage-1 descriptor lifecycle, region tracker stale latch, attention bitmask and its vvar mirror, Rosetta placement and re-entry |
Fork, exec, process, GDB (forkipc.c, fork-state.c, exec.c, proc*.c, gdbstub*.c) |
11 | fork IPC handshake, proc_entry_t, lifecycle registry row, ptrace tracee, pidfd entry, execve point of no return, GDB stop and continue, RSP parser |
FUSE, PTY, procfs, fs.c |
11 | FUSE session, request, mount and file slots; PTY keepalive row and hangup accounting; union directory stream; memfd seals |
fd table, special fds, poll, I/O (fdtable.c, fd.c, poll.c, inotify.c, io.c) |
10 | fd slot, fd_lifetime pin, timerfd, eventfd dup binding, signalfd byte count, epoll registration, io_xfer loop |
USB (usbdev.c, usbdev-fixture.c, usb-sysfs.c) |
10 | endpoint start gate, disconnect state, ready_token, device handle ladder, interface claim |
Threads and futexes (thread.c, futex.c, the run loop in proc.c) |
8 | thread slot, fork quiesce barrier, stop predicate, futex waiter, PI futex word |
Four shapes repeat across these areas:
- Side tables keyed by the guest fd number: eventfd, timerfd, signalfd, inotify, netlink, abstract sockets, the socket-option cache. The state belongs to the open file description, so
dup, close-then-reuse and fork break the lookup. #411 and #412 cover the cleanup and dup halves. - A pipe byte that stands for a level: inotify, eventfd, signalfd, netlink,
ready_tokenin usbdev, the wakeup pipe. Every transition site keeps "pipe readable iff X" by hand. - Flags that some exit path never clears:
on_altstack,noreserve,backing_drained,rlimit_cpu_killing. - Slot lifecycles built from several bools, where the deactivate paths each clean up differently. Three code paths set
thread_entry_t.active = 0, and onlythread_deactivatealso releases signal claims and the fork-barrier count.
Defects caused by a missing transition (found by reading the cited lines, not yet filed):
- Pattern 4.
thread_quiesce_siblings(src/runtime/thread.c) counts every active slot. A vm-clone child that exited but was not reaped stays active and never reaches the barrier. Its exit path invm_clone_thread_run(src/runtime/forkipc.c) skips the step that hands the count back, which the bring-up failure path does take. Every fork therefore waits the full 100 ms timeout while such a child exists. - Pattern 3. Only
rt_sigreturnand exec clearon_altstack(src/syscall/signal.c). When a handler on the alternate stack leaves throughsiglongjmp, nothing clears the flag, andsigaltstack()returns EPERM for the rest of the thread's life. - Pattern 3.
guest_region_t.noreserve(src/core/guest.c) is set at map time and never cleared afterguest_materialize_lazyhas filled the block, so a later translation fault in the same block runs the materialization, and its zero fill, again. - Pattern 2. The host fd behind an inotify fd is the read end of its self-pipe, and only
inotify_readwrites to that pipe (src/syscall/inotify.c). The kqueue event never raises the pipe level, sopollandepoll_waitnever report a file event before the first read.tests/test-inotify.cpasses whenpolltimes out. - The disconnect state in
src/syscall/usbdev.cis set at each completion site.usbdev_async_cbmarks the device disconnected when the main transfer result says the device is gone, but when the zero-length-packet write after it returnskIOReturnNoDevice, that result goes throughusbdev_urb_statusonly and the transition is skipped. - The GDB stop state is held in one flag.
gdb_stub_handle_stop(src/debug/gdbstub.c) clearsstop_requestedbeforethread_interrupt_allkicks the siblings, and the run loop's only stop check (gdb_stub_stop_requestedinsrc/syscall/proc.c) reads that flag alone, so the kicked threads resume guest code during a GDB stop.
Proposal
- File each defect above as its own issue, with a probe, and link it here.
- For the lifecycles that already caused a defect (fd-number side tables, the FUSE request and session, the thread slot, the inotify and signalfd readiness pipes), give the state a named enum and one transition function that checks the from-state, so a skipped transition fails loudly instead of leaving a stale flag.
- Key the fd side tables by open file description or by generation, as usbdev and the pidfd sweep already do (#411).
Alternatives
Fix each defect where it is, with no change to how the state is held. That is smaller per change, but it leaves the next missing transition to be found the same way.
Origin
Related: #411, #412, #511, #479, #384.
- 主要言語
- C
- スター
- 287
- フォーク
- 33
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/elfuse のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
sysprog21/elfuse の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
libreswan/libreswan#3185 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
category:port-update
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
llvm:instcombine
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
llvm/llvm-project#246503 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信