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-7867] [Windows] Swift compiler terminates with memory corruption error while compiling the stdlib #50402

Closed
swift-ci opened this issue Jun 4, 2018 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 4, 2018

Previous ID SR-7867
Radar None
Original Reporter Planitzer (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

OS: Windows 10

SDK: Windows SDK Version 10.0.17134.0

Visual Studio 2017: v15.7.3

Swift: Swift version 4.2-dev (LLVM 58850e66ae, Clang 8c059b98e4, Swift a22b360)

Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels Bug
Assignee @compnerd
Priority Medium

md5: 3cce9d293b1176ec4b2d49b130fe059d

Issue Description:

We've followed the steps listed on this page to try and build the Swift compiler (release version) and stdlib for Windows. The cmark, llvm and the Swift compiler components build successfully but attempting to build the stdlib results in this error:

<unknown>:0: error: compile command failed with exit code -1073740940 (use -v to see invocation)

See the attached "swift_build_steps.txt" for the exact steps that we've executed to build Swift for Windows.

See the attached "swift_build_log.txt" file for the relevant portion of the build log.

See the attached "swift_cmake_config.txt" file for the output of the Swift cmake config step.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 4, 2018

Comment by Dietmar Planitzer (JIRA)

@compnerd I guess that you might most likely be able to give us an hint about what might be wrong / what we can do to fix this / what extra info we could provide to help fix this.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 6, 2018

Comment by Dietmar Planitzer (JIRA)

We've done some more investigation on this by building a RelWithDebInfoAssert version of the Swift compiler and running that in the Visual Studio debugger like this:

Devenv.exe /debugexe C:\Users\dplan\Documents\Developer\swift-repos\build\Ninja-RelWithDebInfoAssert\swift-windows-amd64\bin\swiftc.exe -c -target x86_64-unknown-windows-msvc -resource-dir C:/Users/dplan/Documents/Developer/swift-repos/build/Ninja-RelWithDebInfoAssert/swift-windows-amd64/lib/swift -O -I C:/Users/dplan/Documents/Developer/swift-repos/build/Ninja-RelWithDebInfoAssert/swift-windows-amd64/lib/swift/windows/x86_64 -module-cache-path C:/Users/dplan/Documents/Developer/swift-repos/build/Ninja-RelWithDebInfoAssert/swift-windows-amd64/module-cache -no-link-objc-runtime -Xfrontend -enable-resilience -swift-version 3 -D_USRDLL -Xcc -Xclang -Xcc -ivfsoverlay -Xcc -Xclang -Xcc "C:/Users/dplan/Documents/Developer/swift-repos/build/Ninja-RelWithDebInfoAssert/swift-windows-amd64/windows-sdk-vfs-overlay.yaml" -Xfrontend "-IC:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/include" -Xfrontend "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/ucrt" -Xfrontend "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared" -Xfrontend "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um" -Xfrontend -autolink-library -Xfrontend oldnames -Xfrontend -autolink-library -Xfrontend msvcrtd -module-link-name swiftSwiftPrivateLibcExtras -force-single-frontend-invocation -parse-as-library -o C:/Users/dplan/Documents/Developer/swift-repos/build/Ninja-RelWithDebInfoAssert/swift-windows-amd64/stdlib/private/SwiftPrivateLibcExtras/windows/x86_64/SwiftPrivateLibcExtras.obj C:/Users/dplan/Documents/Developer/swift-repos/swift/stdlib/private/SwiftPrivateLibcExtras/SwiftPrivateLibcExtras.swift C:/Users/dplan/Documents/Developer/swift-repos/swift/stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

The Visual Studio debugger catches a heap corruption exception (see screenshot "heap_corruption_exception") in the LLVM PassManagerBuilder::addExtension() function when it tries to do a std::move() on a static function. It appears that the MS std::move() seems to think that a dynamically allocated function object was passed in and so it tries to free the memory which it shouldn't.

I've attached the stack trace (see "heap_corruption_stack_trace").

@compnerd
Copy link
Collaborator

compnerd commented Jun 9, 2018

I have been building debug rather than release and that does not exhibit this. It has to be an optimization that gets something wrong. It would be helpful to track down where the corruption actually occurs. I guess one other thing that could be interesting would be to try libc++ instead (which I have ported to run on Windows with MS ABI as well) to see if it is the {{std::function}} implementation.

@swift-ci
Copy link
Collaborator Author

Comment by Dietmar Planitzer (JIRA)

@compnerd Thank you for the info.

I've built a debug version of Swift and that doesn't show this crash. I'm able to compile and run certain types of simple Swift apps. Basically anything that doesn't trigger a dynamic cast but I see crashes if the app or stdlib tries to do a dynamic cast. I've written up a separate bug about this with info about what I've been able to find out so far: SR-7991.

Is the clang C++ library part of the llvm-clang project or is this a separate project? I'd like to give this a shot if possible.

@compnerd
Copy link
Collaborator

I believe this has been fixed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants