Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS 104 path length limit. Invalid length for use with domain sockets on this platform. The length must be between 1 and 104 #79503

Closed
ep1kt3t0s opened this issue Dec 11, 2022 · 5 comments
Labels
area-System.IO question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@ep1kt3t0s
Copy link

ep1kt3t0s commented Dec 11, 2022

Description

On MacOS (13.0.1, Apple Silicon) with dotnet 6.0.403 and 6.0.400 I got the below issue with paths being restricted to 104 characters.
I do think MacOS allows paths longer than 104, so I'm not sure where the 104 is coming.
I found this below code snippet that which I believe sets the 104 character limit but I could not run it on my dev environment.
Interop.Sys.GetDomainSocketSizes(out s_nativePathOffset, out s_nativePathLength, out s_nativeAddressSize);

But I am also using Path.GetTempPath() to get a work directory which produces a path like /var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/, which is quite long already.

The rest of the socket pipe, coming from using ffmpeg but I don't think related to it, creates a path of CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b and combination of these exceed 104 characters.

I do believe something might be wrong on MacOS with 104 character limit and might be better to check it out.

System.ArgumentOutOfRangeException: The path '/var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b' is of an invalid length for use with domain sockets on this platform.  The length must be between 1 and 104 characters, inclusive. (Parameter 'path')
      Actual value was /var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b.
         at System.Net.Sockets.UnixDomainSocketEndPoint..ctor(String path, String boundFileName)
         at System.Net.Sockets.UnixDomainSocketEndPoint..ctor(String path)
         at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path, Int32 maxCount)
         at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path, Int32 maxCount)
         at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
         at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options)

Reproduction Steps

Create a named pipe from a socket within the directory Path.GetTempPath().

Expected behavior

Should not error for 104 character limit on MacOS.

Actual behavior

Errors for 104 character limit on MacOS.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 11, 2022
@ghost
Copy link

ghost commented Dec 11, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

On MacOS (13.0.1, Apple Silicon) with dotnet 6.0.403 and 6.0.400 I got the below issue with paths being restricted to 104 characters.
I do think MacOS allows paths longer than 104, so I'm not sure where the 104 is coming.

But I am also using Path.GetTempPath() to get a work directory which produces a path like /var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/, which is quite long already.

The rest of the socket pipe, coming from using ffmpeg but I don't think related to it, creates a path of CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b and combination of these exceed 104 characters.

I do believe something might be wrong on MacOS with 104 character limit and might be better to check it out.

System.ArgumentOutOfRangeException: The path '/var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b' is of an invalid length for use with domain sockets on this platform.  The length must be between 1 and 104 characters, inclusive. (Parameter 'path')
      Actual value was /var/folders/7b/tkffkjy54676nvv44rpvv1l40000gn/T/CoreFxPipe_FFMpegCore_782288f0-1e42-4550-ab59-5a5161581e5b.
         at System.Net.Sockets.UnixDomainSocketEndPoint..ctor(String path, String boundFileName)
         at System.Net.Sockets.UnixDomainSocketEndPoint..ctor(String path)
         at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path, Int32 maxCount)
         at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path, Int32 maxCount)
         at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
         at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options)

Reproduction Steps

Create a named pipe from a socket within the directory Path.GetTempPath().

Expected behavior

Should not error for 104 character limit on MacOS.

Actual behavior

Errors for 104 character limit on MacOS.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: ep1kt3t0s
Assignees: -
Labels:

area-System.IO

Milestone: -

@stephentoub
Copy link
Member

https://man.openbsd.org/unix.4

"UNIX-domain addresses are variable-length filesystem pathnames of at most 104 characters."

We don't hardcode the length. It comes directly from the os:

*pathSize = sizeof(domainSocket.sun_path);

@ep1kt3t0s
Copy link
Author

Surprising the limit is only 104 characters. I actually did not hit this limit on Ubuntu but hitting it on MacOS.

@stephentoub
Copy link
Member

On Linux the limit is typically 108 and the default temp path is usually much shorter.

@stephentoub stephentoub added the question Answer questions and provide assistance, not an issue with source code or documentation. label Dec 11, 2022
@stephentoub stephentoub closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Dec 11, 2022
@ep1kt3t0s
Copy link
Author

Thank you for the clarification @stephentoub

@ghost ghost locked as resolved and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

2 participants