-
Notifications
You must be signed in to change notification settings - Fork 4.7k
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Can we lift the name length limitation on semaphores? #15399
Comments
/cc @JeremyKuhne @ericeil |
I think this would be nice, but am concerned about relying on undocumented OS behavior. Also, this doesn't seem as compelling to me as the long file paths work; file paths are user-visible, so there are good reasons for them to be long. Semaphore names are not visible, and so can be generated any number of ways, including the hashing scheme @poizan42 has already suggested. |
I understand the concern about undocumented behaviour. On the other hand this is a compatibility constraint. There is already going to be applications out there that will stop working if the length limit is enforced, and I don't really see a reason why it should be in the future. Maybe one of you Microsoft insiders could ask the relevant team whether it's ok to rely on (and in that case the documentation could be updated)?. |
As an aside, while a direct call to |
Yes that is my point. However the documentation for CreateSemaphore claims that is should have a limit of 260 characters even though that isn't enforced. The real limit is probably 2^15 - 30 or a bit less depending on whether it's a global or local semaphore and what the session id is. |
@poizan42 Agree, it's even more conspicuous that enforcing this limitation or not differs depending on how you create the Semaphore. It's a huge inconsitency at the very least. |
We are fine with removing the 'artificial' MAX_PATH enforcement in .NET Core code and leave the limit check on underlying OS. |
I'm fine with removing this as well. Just make sure there is a test that creates a semaphore with a length greater than MAX_PATH (1K would be a good choice) and add a comment that we're letting the API kick back names that are too long rather than pre-validating them. If, for some reason, we get back an error that says the name is too long (say, with a 10K name or on Windows 7) we should make sure it maps to ArgumentException. |
Fixed by dotnet/coreclr#18402 |
Now that we have more-or-less gotten rid of the path length limitation (#645), could we also get rid of the semaphore name length restriction? The documentation for CreateSemaphore claims that the name is limited to MAX_PATH characters, however testing this shows that the documentation is wrong (at least on Windows 10):
Running this prints OK followed by the handle. Setting a breakpoint before CloseHandle and inspecting the handles shows that the semaphore is indeed created with the full name:
Edit: It would be a good idea if I posted the same code that I ran when I took the screenshot :)
The text was updated successfully, but these errors were encountered: