Skip to content

POSIX MSYS2 runtime strips {} from arguments when launching processes with CreateProcess #332

@ikappaki

Description

@ikappaki

When a program built with the MSYS2 POSIX runtime is launched via CreateProcess, any arguments containing {} are stripped before reaching the child process. Programs built with MSYS2/MINGW64 runtime preserve the arguments as expected.

A minimal repro is included in https://github.com/ikappaki/issue-msys2-createprocess.

  • wrapper.c — launches a target executable and forwards arguments.
  • echo2.c — prints received arguments.

Steps to reproduce:

Follow README.md instructions:

  1. Build wrapper in MINGW64.
  2. Build echo2 in both MINGW64 and MSYS2 POSIX.
  3. Run the wrapper with echo2 and arguments containing {}.

Running the programs directly preserves {}:

$ ./echo2.x86_64.exe 1 {2} 3
1 {2} 3
$ ./echo2.msys2.exe 1 {2} 3
1 {2} 3

Launching via wrapper triggers the POSIX runtime issue:

# OK (MINGW64 target)
./wrapper.x86_64.exe ./echo2.x86_64.exe 1 {2} 3
# Executing: "./echo2.x86_64.exe" 1 {2} 3
# 1 {2} 3

# ISSUE (MSYS2 POSIX target)
./wrapper.x86_64.exe ./echo2.msys2.exe 1 {2} 3
# Executing: "./echo2.msys2.exe" 1 {2} 3
# 1 2 3

The second argument loses the {} when using the MSYS2 POSIX runtime.

Same behaviour occurs with /usr/bin/echo

$ ./wrapper.x86_64.exe /usr/bin/echo 1 {2} 3
# Executing: "D:/msys64/usr/bin/echo" 1 {2} 3
# 1 2 3

Expected behavior:
All arguments, including {}, are passed unchanged.

Actual behavior (POSIX runtime):
Curly braces are stripped from the arguments.

Notes:

  • Only occurs with MSYS2 POSIX executables.
  • Likely related to argument conversion in the POSIX layer before CreateProcess.
  • Impacts CLI tools or scripts that rely on {} in arguments, such as invoking git from a process like git --git-dir C:\abc rev-parse 12345678abcde^{commit}.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions