Repository navigation
fix(id): bound clap derive stack use in CLI parse path - #5329
Conversation
Every Cli parse overflowed the default thread stack in debug builds, aborting the pkgs/id lib test binary (SIGABRT) and masking its whole test signal. gdb showed the fault inside the derive-generated augment_subcommands chain (Cli -> Command -> WorldCommand): clap inlines a struct-style variant's argument construction into the parent enum's generated functions, and the summed frames of the largest variants exceeded the stack. It was finite but unbounded-by-design stack growth, not infinite recursion: parses passed with a 16 MiB stack and failed at the 2 MiB default. Fix at the production source, not the test stack: extract the largest struct-style variants into their own Args structs so their construction lives in its own generated functions - - Command::Serve (~100 flags) -> Serve(ServeArgs) - 24 WorldCommand variants with >=4 flags -> World<Name>Args tuple variants Measured on the laptop at the default test-thread stack: the three named tests (module_trust_keys_are_repeatable_and_require_world_mode, test_cli_parse_world_new_and_stats, flag_defaults_match_the_built_in_limits) went from stack-overflow aborts to passing, and the full pkgs/id lib suite now runs to completion: 2105 passed, 0 failed, 6 ignored.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
agent-note:v1 — task 8955 (lane code-n) resuming this PR for merge. CI disposition: the only failing check, |
|
🤖 Agent note · handed off (task 9313) Claimed by lane code-h and assigned to the opencode execution lane (§1b) — handed to the bound opencode claimant session for the disposition itself; the sandbox lane does not work this task itself. Revalidation leads for the claimant (fresh
|
Fixes #4751
Problem
Every
Cliparse overflowed the default thread stack in debug builds, aborting thepkgs/idlib test binary (SIGABRT, exit 101) and masking its entire test signal (~2100 tests). The three named tests were simply the first to hit it in each module.Diagnosis (gdb + stack probes, laptop)
augment_subcommandschainCli -> Command -> WorldCommand.RUST_MIN_STACK=16MiB, failed at the 2 MiB default; eventest_cli_parse_no_argsoverflowed.Command::Serveat ~100 flags;WorldCommand's 29 variants at 147 flags) exceeded the stack. Probes:WorldCommand::augment_subcommandsalone needed ~1.5–2 MiB.Fix
Extract the largest struct-style variants into their own
Argsstructs (tuple variants), so each construction lives in its own generated function and the parent enums' frames stay small:Command::Serve->Serve(ServeArgs)WorldCommandvariants with >=4 flags ->World<Name>ArgsCall sites updated mechanically (pattern -> tuple + one destructure line); no CLI surface change: same subcommands, same flags, same defaults.
Verification (laptop, default test-thread stack)
cli::tests::module_trust_keys_are_repeatable_and_require_world_mode,cli::tests::test_cli_parse_world_new_and_stats,cli::world_limits_args_tests::flag_defaults_match_the_built_in_limits.pkgs/idlib suite runs to completion: 2105 passed; 0 failed; 6 ignored (previously aborted by SIGABRT).cargo check -p id --all-targets(via manifest) clean; rustfmt applied.Queue: task 8953 (repo-health-code-pilot), lane code-t.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.