mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Box the TUI future to bound CLI stack usage (#39154)
## Why The TUI startup future is large enough to inflate the CLI dispatcher's stack frame. ## What changed - Heap-pin the TUI startup future before awaiting it. - Add a regression test that keeps the `run_interactive_tui` future below 64 KiB. GitOrigin-RevId: 1f977928117537a5188c4d801517fb4a42e39e15
This commit is contained in:
1 parent
539a09cb28
commit
3d47dc40be
1 file changed
+15
-1
@@ -2567,7 +2567,8 @@ async fn run_interactive_tui(
|
|||||||
};
|
};
|
||||||
let mut attempted_backups = HashSet::new();
|
let mut attempted_backups = HashSet::new();
|
||||||
loop {
|
loop {
|
||||||
let err = match start_tui().await {
|
// Keep the large TUI future out of the CLI dispatcher's stack frame.
|
||||||
|
let err = match Box::pin(start_tui()).await {
|
||||||
Ok(exit_info) => return Ok(exit_info),
|
Ok(exit_info) => return Ok(exit_info),
|
||||||
Err(err) => err,
|
Err(err) => err,
|
||||||
};
|
};
|
||||||
@@ -2795,6 +2796,19 @@ mod tests {
|
|||||||
use codex_tui::TokenUsage;
|
use codex_tui::TokenUsage;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn interactive_tui_future_stays_bounded() {
|
||||||
|
let future = run_interactive_tui(
|
||||||
|
TuiCli::parse_from(["codex"]),
|
||||||
|
/*remote*/ None,
|
||||||
|
/*remote_auth_token_env*/ None,
|
||||||
|
Arg0DispatchPaths::default(),
|
||||||
|
);
|
||||||
|
let size = std::mem::size_of_val(&future);
|
||||||
|
|
||||||
|
assert!(size < 64 * 1024, "interactive TUI future is {size} bytes");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn updater_http_client_factory_honors_respect_system_proxy() {
|
async fn updater_http_client_factory_honors_respect_system_proxy() {
|
||||||
let codex_home = tempfile::tempdir().expect("temporary Codex home");
|
let codex_home = tempfile::tempdir().expect("temporary Codex home");
|
||||||
|
|||||||
Reference in new issue
Block a user