Skip to content

Fix clio wallet CLI option storage lifetime - #371

Merged
huangminghuang merged 1 commit into
masterfrom
feature/fix-clio-wallet-asan
Jun 5, 2026
Merged

huangminghuang merged 1 commit into
masterfrom
feature/fix-clio-wallet-asan

Conversation

@huangminghuang

Copy link
Copy Markdown
Contributor

Problem

The ASAN job in PR #369 failed during the regular parallel test phase before the sharded NP/LR tests ran:

ERROR: AddressSanitizer: stack-use-after-scope
...
CLI::App::add_option<std::string>(...)
...
clio wallet import --name ignition --private-key ...

clio registered CLI11 options backed by strings declared inside short wallet subcommand setup blocks. CLI11 keeps references to those option targets and invokes parse/callback logic after those blocks have exited, so ASAN correctly reports use-after-scope when wallet import writes to wallet_key_str.

Fix

Hoist the wallet subcommand option storage to the lifetime of the wallet command setup in main, covering:

  • wallet import
  • wallet remove_key
  • wallet remove_name
  • wallet create_key
  • wallet set_key_name

This keeps the existing CLI behavior while ensuring CLI11 option targets outlive parse and callback execution.

Verification

  • Configured a local build in build/clio-asan-fix.
  • Built clio successfully:
cmake --build build/clio-asan-fix --target clio -- -j6
  • Checked the affected command still parses help:
./build/clio-asan-fix/programs/clio/clio wallet import --help

@huangminghuang
huangminghuang requested a review from heifner June 5, 2026 16:14
@huangminghuang
huangminghuang merged commit 1c32651 into master Jun 5, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants