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
Comments
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. |
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:
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"). |
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. |
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. |
I believe this has been fixed. |
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
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:
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.
The text was updated successfully, but these errors were encountered: