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

[SR-14976] Swift Package Manager (SPM) on Windows: BUFFER OVERFLOW on PreferredUILanguages/MachinePreferredUILanguages #4398

Closed
swift-ci opened this issue Jul 26, 2021 · 12 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-14976
Radar None
Original Reporter Stefan Springer (JIRA User)
Type Bug
Status Closed
Resolution Invalid
Environment

Windows 10 Home in a Parallels 16 VM under macOS 11.5 on Intel using swift-5.4.2-RELEASE

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, Windows
Assignee None
Priority Medium

md5: bf5b17b5707e16340adfddbea40948f8

is duplicated by:

  • SR-14977 (DUPLICATE to SR-14976) Swift Package Manager (SPM) on Windows: BUFFER OVERFLOW on PreferredUILanguages/MuiCached\MachinePreferredUILanguages

Issue Description:

I had a Windows where German was the only installed language, and SPM got stuck after displaying the first "Fetching ..." (see my comment from July 25 and 26 on https://forums.swift.org/t/stochastic-errors-resolving-dependencies-and-or-building-with-feb-18-2021-snapshot/44929.)). Using Process monitor, I found:

swift.exe: RegQueryValue: BUFFER OVERFLOW: HKCU\Control Panel\Desktop\PreferredUILanguages
swift.exe: RegQueryValue: BUFFER OVERFLOW: HKCU\Control Panel\Desktop\MuiCached\MachinePreferredUILanguages

After adding dding "English (United States)"" as additional language and then setting the system language to English, the SPM then first went further (and displayed another error message about false package version which is also not OK as a message, but maybe that is another issue), but on another ty it again got stuck with the above errors.

An error that was always displayed in the process monitor was:

swift.exe: RegQueryValue: BUFFER TOO SMALL: HKLM\System\CurrentControlSet\Control\Notifications\418A073AA3BC8075

(The Swift package was https://github.com/stefanspringer1/SwiftXMLParserDemo.)

@typesanitizer
Copy link

cc @compnerd

@compnerd
Copy link
Collaborator

I suspect that the crux of the issue is that there is something wrong with your package setup, and that is causing a diagnostic to be emitted. However, the diagnostic cannot be emitted because you do not have the English language available.

The RegQueryValue calls are not from the Swift compiler or Swift runtime, we do not call into the registry directly ever. The likely places where this is occurring is either Foundation or Swift Package Manager. I would suspect that this is more likely SPM, with the path being in swift-tools-support-core with something related to paths. What is also interesting is that there is no call to `FormatMessage` that I could see that would require the English language support. I wonder if this is a Swift standard library issue?

@compnerd
Copy link
Collaborator

@compnerd
Copy link
Collaborator

One thing that may be useful is to set a conditional breakpoint on RegQueryValue and see what is calling into it.

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

I suspect that the crux of the issue is that there is something wrong with your package setup, and that is causing a diagnostic to be emitted

On macOS, no error is committed when running `swift build -c release` for the package, even after removing `/Users/<user>/Library/Caches/org.swift.swiftpm`. And the repository and the dependent repositories are really simple. And there are no non-ASCII characters in the filenames. I think the packages are OK.

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

I think the packages are OK.

Aha, you seem to be right, after starting Windows again, indeed an error war printed (Swift wanted to have swift-tools-version:5.4.0 instead of 5.3), I fixed that (also in the dependant repositories and changed "target" to "executableTarget" to avoid warnings). So I think the problem persist that SPM is not working correctly on Windows when no English language is present (and you have errors?).

BTW: Now SPM says "Dependencies could not be resolved because no versions of 'SwiftXMLParser' match the requirement 0.1.18..<1.0.0 and root depends on 'SwiftXMLParser' 0.1.18..<1.0.0" which is not correct. OK, that has nothing to do with the issue described here (but still a main point for me since I cannot build on Windows 🙁 ).

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

Update: When trying again, SPM again gets stuck with the mentioned errors in Process Monitor. Seems to be a sporadic thing? (I did not change anything in the Windows settings, and no restart of Windows).

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

Any progress on this issue? I now tried Swift version 5.6-dev, and swift build seems to go a little bit further now, displaying "Computing version for ..." but then again stuck and doing nothing, meanwhile displaying errors in Process Monitor: swift.exe: RegQueryValue / BUFFER TOO SMALL, swift.exe: RegQueryValue / BUFFER OVERFLOW, etc. etc.. What can I do to make Swift (with SPM) usable on Windows? Any idea? Thanks!

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

See a newer discussion on a new Swift forums entry.

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

Some of the issues I ran into were solved by things that should be documented on the Getting Started page, see the new ticket #SR-15125 for suggestions of what to add there.

Still remains one issue for me, see the new ticket #SR-15126.

For this ticket: I do not know if the above BUFFER OVERFLOW errors are related my persisting problem or if they are somehow substantial. But somehow I think there should not be those errors.

@compnerd
Copy link
Collaborator

This warning is not from the Swift tooling but from other processes on the host. There is nothing that we can do here.

@swift-ci
Copy link
Contributor Author

Comment by Stefan Springer (JIRA)

This warning is not from the Swift tooling but from other processes on the host. There is nothing that we can do here.

The process monitor says that it is coming from swift.exe. But OK; I am not an expert here.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants