Skip to content

os/exec: Combined number of symbols in file paths are causing error if it exceeds ~2^15 symbols combined. #21145

Closed
@ghost

Description

Hello,

What version of Go are you using (go version)?

go1.8.3

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\trumpe\PROJECTS\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

To begin, I pulled 507 files on my work repository. All files were in one folder and package. When I tried to compile I got an error:

go build good: C:\Go\pkg\tool\windows_amd64\compile.exe: fork/exec C:\Go\pkg\tool\windows_amd64\compile.exe: The filename or extension is too long.
exit status 1
Process exiting with code: 1

After some investigation I found out that no filename or extension were too long, also the number of files in the package has nothing to do with. The problem occurs when a sum of all file paths in a package exceeds 2^15(My guess only, because it depends on other paths as well. When I was testing it was always between 31740 and 31830 symbols, so my best guess some internal files are counted as well and 2^15 makes most sense), or around 32k symbols.
To clarify you can have around 640 files with filepaths "C:\Users\trumpe\PROJECTS\Go\src\testing1\file01.go" --> (50 symbols)
or for example 800 files with filepaths
"C:\Users\PROJECTS\Go\src\testfile0001.go" --> (40 symbols)
As long as it adds up to approx. 32000 symbols from all the files in the package.

I tried to recreate the problem by generating files and compiling them and everytime I came up to the same conclusion.

The files that I pulled were written on Linux Centos6.8 so I believe it is a Windows problem only.

Unfortunately it is against my company policy to reveal any source code I was using, that's why I created random files to recreate the problem. Powershell scripts to recreate the problem are provided below.

https://play.golang.org/p/6bjmwD9gS4

What did you expect to see?

I expected to compile the package and run the program.

What did you see instead?

go build good: C:\Go\pkg\tool\windows_amd64\compile.exe: fork/exec C:\Go\pkg\tool\windows_amd64\compile.exe: The filename or extension is too long.
exit status 1
Process exiting with code: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions