Too small ARG_MAX value for command line parameter length #14660

Closed
opened 2026-01-31 04:16:12 +00:00 by claunia · 3 comments
Owner

Originally created by @Okeanos on GitHub (Jul 23, 2021).

Description of the new feature/enhancement

The Windows Terminal (probably conhost) command line parameter length and number are severely limited. As far as I can currently tell on a reasonably up to date Windows 10 version the ARG_MAX value, i.e maximum number of bytes that a single command may consume at once during invocation is limited to 32000 bytes. Some additional details around that here and here.

Other platforms have much higher limits that make working with large arguments/argument lists way easier. A particular instance where this is a particular problem on Windows (but generally everywhere at some point) is when one wants to use govc to manipulate vSphere VMs (vmware/govmomi/issues/2488).

This may not be the exact right place for this request but may be a core issue of the Windows platform? Sorry in that case but maybe you can forward this request ;-)

Proposed technical implementation details (optional)

I would want the limit raised to a larger reasonable default, probably at a minimum to what macOS (262144 bytes) also supports for consistency across various platforms.

Originally created by @Okeanos on GitHub (Jul 23, 2021). # Description of the new feature/enhancement The Windows Terminal (probably conhost) command line parameter length and number are severely limited. As far as I can currently tell on a reasonably up to date Windows 10 version the `ARG_MAX` value, i.e maximum number of bytes that a single command may consume at once during invocation is limited to `32000 bytes`. Some additional details around that [here](https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553) and [here](https://www.in-ulm.de/~mascheck/various/argmax/). Other platforms have much higher limits that make working with large arguments/argument lists way easier. A particular instance where this is a particular problem on Windows (but generally everywhere at some point) is when one wants to use [govc](https://github.com/vmware/govmomi/tree/master/govc) to manipulate vSphere VMs (vmware/govmomi/issues/2488). This may not be the exact right place for this request but may be a core issue of the Windows platform? Sorry in that case but maybe you can forward this request ;-) # Proposed technical implementation details (optional) I would want the limit raised to a larger reasonable default, probably at a minimum to what macOS (`262144 bytes`) also supports for consistency across various platforms.
claunia added the Issue-FeatureProduct-ConhostNeeds-TriageNeeds-Tag-FixzInbox-Bug labels 2026-01-31 04:16:12 +00:00
Author
Owner

@eryksun commented on GitHub (Jul 23, 2021):

The command-line string in Windows can contain up to 32K wide characters (64 KiB). The limit is fixed in the process parameters record, for which the CommandLine is of type UNICODE_STRING. Even if the OS supported a longer command-line string, applications can have their own limits that would also need to be extended. For example, the CMD shell limits command-line strings to 8K characters.

Alternatively, a PROC_THREAD_ATTRIBUTE_ARGUMENT_LIST attribute could be implemented to store a variable-sized argument list in the process parameters. If the attribute isn't set, CreateProcessW() can parse the argument list from lpCommandLine. If the attribute is set and lpCommandLine is NULL, CreateProcessW() can create the command-line string from the argument list. Add a GetArgvW() API function to fetch the argument list of the current process. Applications would have to be updated to replace calls to GetCommandLineW() and CommandLineToArgvW() with a single GetArvW() call.

@eryksun commented on GitHub (Jul 23, 2021): The command-line string in Windows can contain up to 32K wide characters (64 KiB). The limit is fixed in the [process parameters record](https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters), for which the `CommandLine` is of type [`UNICODE_STRING`](https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_unicode_string). Even if the OS supported a longer command-line string, applications can have their own limits that would also need to be extended. For example, the CMD shell limits command-line strings to 8K characters. Alternatively, a `PROC_THREAD_ATTRIBUTE_ARGUMENT_LIST` attribute could be implemented to store a variable-sized argument list in the process parameters. If the attribute isn't set, `CreateProcessW()` can parse the argument list from `lpCommandLine`. If the attribute is set and `lpCommandLine` is `NULL`, `CreateProcessW()` can create the command-line string from the argument list. Add a `GetArgvW()` API function to fetch the argument list of the current process. Applications would have to be updated to replace calls to `GetCommandLineW()` and `CommandLineToArgvW()` with a single `GetArvW()` call.
Author
Owner

@Okeanos commented on GitHub (Jul 23, 2021):

For my use case I am particularly interested in calling applications via a Git Bash embedded into the Windows Terminal – the underlying mintty/msys process appears to honour the ARG_MAX value I initially reported.

I am not entirely sure whether your reference to the CMD shell (cmd.exe, i.e. classic Windows command line?) means this is something the conhost as underlying process or mintty/msys/cygwin (which apparently has its own limit slightly below the Windows limit for safety) as base shell applications have to implement. I'd be perfectly happy to raise the issue over there.

@Okeanos commented on GitHub (Jul 23, 2021): For my use case I am particularly interested in calling applications via a Git Bash embedded into the Windows Terminal – the underlying mintty/msys process appears to honour the `ARG_MAX` value I initially reported. I am not entirely sure whether your reference to the CMD shell (`cmd.exe`, i.e. classic Windows command line?) means this is something the conhost as underlying process or mintty/msys/cygwin (which apparently has its [own limit](https://www.in-ulm.de/~mascheck/various/argmax/) slightly below the Windows limit for safety) as base shell applications have to implement. I'd be perfectly happy to raise the issue over there.
Author
Owner

@carlos-zamora commented on GitHub (Mar 16, 2023):

Unfortunately, this is a Windows platform limitation that we are not well positioned to fix. We will bring this up with the appropriate parties, but we can't make any promises about whether this can be fixed. Thanks for the feedback!

@carlos-zamora commented on GitHub (Mar 16, 2023): Unfortunately, this is a Windows platform limitation that we are not well positioned to fix. We will bring this up with the appropriate parties, but we can't make any promises about whether this can be fixed. Thanks for the feedback!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14660