Swift REPL crashes upon `import Foundation`

This broke for me some time ago and it would really be nice to have a REPL again.
Any clues for what might cause this?

bash-3.2$ swift
Welcome to Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9).
Type :help for assistance.
  1> import Foundation
warning: Swift error in fallback scratch context: /System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9:9: note: while building module 'Security' imported from /System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9:
#import <Security/Security.h>
        ^

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Security.h"
        ^

/System/Library/Frameworks/Security.framework/Headers/Security.h:98:10: note: in file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:98:
#include <Security/CMSDecoder.h>
         ^

error: /System/Library/Frameworks/Security.framework/Headers/CMSDecoder.h:130:5: error: expected function body after function declarator
    __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_5, __MAC_10_13, __IPHONE_NA, __IPHONE_NA,
    ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Availability.h:291:57: note: expanded from macro '__OSX_AVAILABLE_BUT_DEPRECATED_MSG'
                                                        __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg)
                                                        ^

<scratch space>:74:1: note: expanded from here
__AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_13_MSG
warning: <module-includes>:1:1: warning: umbrella header for module 'Security' does not include header 'SecProtocol.h'
#import "Headers/Security.h"
^

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Foundation.h"
        ^

/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:85:9: note: in file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:85:
#import <Foundation/NSURLCredential.h>
        ^

error: /System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9:9: error: could not build module 'Security'
#import <Security/Security.h>
        ^

/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:15:9: note: while building module 'CoreServices' imported from /System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:15:
#import <CoreServices/CoreServices.h>
        ^

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/CoreServices.h"
        ^

/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:45:10: note: in file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:45:
#include <LaunchServices/LaunchServices.h>
         ^

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:23:10: note: in file included from /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:23:
#include <LaunchServices/IconsCore.h>
         ^

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23:10: note: in file included from /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23:
#include <OSServices/OSServices.h>
         ^

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Headers/OSServices.h:29:10: note: in file included from /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Headers/OSServices.h:29:
#include <OSServices/CSIdentity.h>
         ^

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Headers/CSIdentity.h:26:10: note: in file included from /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Headers/CSIdentity.h:26:
#include <OSServices/CSIdentityBase.h>
         ^

error: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Headers/CSIdentityBase.h:23:10: error: could not build module 'Security'
#include <Security/SecBase.h>
         ^

/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8:9: note: while building module 'ApplicationServices' imported from /System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8:
#import <ApplicationServices/ApplicationServices.h>
        ^

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/ApplicationServices.h"
        ^

error: /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:10: error: could not build module 'CoreServices'
#include <CoreServices/CoreServices.h>
         ^

error: could not build Objective-C module 'Foundation'


note: This error message is displayed only once. If the error displayed above is due to conflicting search paths to Clang modules in different images of the debugged executable, this can slow down debugging of Swift code significantly, since a fresh Swift context has to be created every time a conflict is encountered.

0  lldb                     0x000000010db34705 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  lldb                     0x000000010db33d77 llvm::sys::RunSignalHandlers() + 39
2  lldb                     0x000000010db34d58 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff6cf85b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00007f942273b4f0 _sigtramp + 3044759984
5  LLDB                     0x000000010e04ef33 std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*>, void*>*>, std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*>, void*>*> > std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, swift::ValueDecl*> > >::__equal_range_multi<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 19
6  LLDB                     0x000000010e04eb05 lldb_private::SwiftPersistentExpressionState::SwiftDeclMap::FindMatchingDecls(lldb_private::ConstString, std::__1::vector<swift::ValueDecl*, std::__1::allocator<swift::ValueDecl*> > const&, std::__1::vector<swift::ValueDecl*, std::__1::allocator<swift::ValueDecl*> >&) + 213
7  LLDB                     0x000000010e04ed0c lldb_private::SwiftPersistentExpressionState::GetSwiftPersistentDecls(lldb_private::ConstString, std::__1::vector<swift::ValueDecl*, std::__1::allocator<swift::ValueDecl*> > const&, std::__1::vector<swift::ValueDecl*, std::__1::allocator<swift::ValueDecl*> >&) + 28
8  LLDB                     0x000000010dde61a5 lldb_private::ExpressionSourceCode::GetText(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb::LanguageType, unsigned int, lldb_private::EvaluateExpressionOptions const&, lldb_private::ExecutionContext&, unsigned int&) const + 4677
9  LLDB                     0x000000010e05365d lldb_private::SwiftUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) + 509
10 LLDB                     0x000000010de0195a lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, llvm::StringRef, llvm::StringRef, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::Status&, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::shared_ptr<lldb_private::Module>*) + 2858
11 LLDB                     0x000000010ddff5f1 lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 2129
12 LLDB                     0x000000010dd749d0 lldb_private::IOHandlerEditline::Run() + 368
13 LLDB                     0x000000010dd5bdab lldb_private::Debugger::ExecuteIOHandlers() + 123
14 LLDB                     0x000000010dd5e7f3 lldb_private::Debugger::IOHandlerThread(void*) + 19
15 LLDB                     0x000000010de090b7 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 103
16 libsystem_pthread.dylib  0x00007fff6cf8e2eb _pthread_body + 126
17 libsystem_pthread.dylib  0x00007fff6cf91249 _pthread_start + 66
18 libsystem_pthread.dylib  0x00007fff6cf8d40d thread_start + 13
Segmentation fault: 11
bash-3.2$

Please file a bug report at bugs.swift.org

Done. Thanks
https://bugs.swift.org/browse/SR-12293

1 Like