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

Crash while compiling simple program #69891

Open
migueldeicaza opened this issue Nov 15, 2023 · 0 comments
Open

Crash while compiling simple program #69891

migueldeicaza opened this issue Nov 15, 2023 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@migueldeicaza
Copy link

migueldeicaza commented Nov 15, 2023

Description

The following simple program crashes the Swift compiler:

class Demo {
    var output: TextOutputStream
    init (o: TextOutputStream) {
        self.output = o
    }

    func x () {
        print ("a", to: &output)
    }
}

Steps to reproduce

Put the above text snippet into a file, and then invoke the compiler like this:

swiftc -c demo.swift

Expected behavior

It should compile without a crash, instead you get:

1.	Apple Swift version 5.9.2 (swiftlang-5.9.2.2.51 clang-1500.1.0.2.2)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "/tmp/a.swift")
4.	While emitting IR SIL function "@$s1a4DemoV1xyyF".
 for 'x()' (at /tmp/a.swift:7:14)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001083a4c40 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001083a39dc llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001040ee668 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x00000001829e1a24 _sigtramp + 56
4  swift-frontend           0x0000000106b20f10 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::irgen::DynamicMetadataRequest) + 288
5  swift-frontend           0x00000001056280c0 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) + 252
6  swift-frontend           0x000000010407a160 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 292
7  swift-frontend           0x0000000104aad940 swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::GenericRequirement, swift::MetadataState, swift::SubstitutionMap, bool) + 264
8  swift-frontend           0x0000000103b4304c void llvm::function_ref<void (swift::GenericRequirement)>::callback_fn<(anonymous namespace)::EmitPolymorphicArguments::emit(swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&)::$_17>(long, swift::GenericRequirement) + 64
9  swift-frontend           0x0000000103b44464 void llvm::function_ref<void (swift::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::GenericRequirement)> const&)::$_8>(long, swift::GenericRequirement) + 212
10 swift-frontend           0x0000000104adc4e0 void llvm::function_ref<void (swift::GenericTypeParamType*, bool)>::callback_fn<swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::GenericRequirement)> const&)::$_0>(long, swift::GenericTypeParamType*, bool) (.llvm.13441421060209707708) + 76
11 swift-frontend           0x0000000105fb51c4 swift::GenericSignatureImpl::forEachParam(llvm::function_ref<void (swift::GenericTypeParamType*, bool)>) const + 752
12 swift-frontend           0x00000001069e1d38 swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::GenericRequirement)> const&) + 148
13 swift-frontend           0x0000000106a22cfc swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 344
14 swift-frontend           0x0000000107c26a50 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 3784
15 swift-frontend           0x0000000107a38898 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2788
16 swift-frontend           0x000000010313a580 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 11680
17 swift-frontend           0x0000000105639244 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 2516
18 swift-frontend           0x0000000103ceea98 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 6532
19 swift-frontend           0x0000000107a13698 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 176
20 swift-frontend           0x00000001074ab80c llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 1480
21 swift-frontend           0x0000000107210b4c swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 264
22 swift-frontend           0x0000000107c4b024 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
23 swift-frontend           0x0000000107c53df0 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1596
24 swift-frontend           0x0000000107c4dc30 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
25 swift-frontend           0x0000000107c51e6c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
26 swift-frontend           0x0000000107cb0864 swift::mainEntry(int, char const**) + 4408
27 dyld                     0x0000000182639058 start + 2224
Segmentation fault: 11

Environment

Happens with both Xcode 15.0, and the 15.1 beta, the version for the beta:

  • Swift compiler version info swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.51 clang-1500.1.0.2.2)

  • Xcode version info 15.0 15A240d (but also happens with the beta)

  • Deployment target: MacOS, or iOS.

@migueldeicaza migueldeicaza added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Nov 15, 2023
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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant