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-14084] swift build Int to Int32 leads segmentation fault 11 #56473

Open
swift-ci opened this issue Jan 22, 2021 · 4 comments
Open

[SR-14084] swift build Int to Int32 leads segmentation fault 11 #56473

swift-ci opened this issue Jan 22, 2021 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14084
Radar rdar://problem/73519267
Original Reporter Naixor (JIRA User)
Type Bug

Attachment: Download

Environment

swift --version

Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)

Target: x86_64-apple-darwin19.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 091567b3da8aa9bde582b50d07bce2b8

Issue Description:

main.swift


**import** Foundation

**class** A {

**private** **var** arr: [**Any**] = []

**@objc**

**init**()
Unknown macro: \{         **let** i32 = Int32(arr.count)     }
}

Makfile

SDKPATH = xcrun --show-sdk-path -sdk iphonesimulator
TARGET = 'x86_64-apple-ios14.0-simulator'

build_main:
swift -frontend -c main.swift -Xcc -working-directory -Xcc $(CURDIR) -whole-module-optimization -O -enable-objc-interop -emit-module -emit-objc-header -sdk $(SDKPATH) -module-name Main -target-sdk-version 14.0 -I$(CURDIR)/Enum -F$(CURDIR)/Enum -framework Enum -swift-version 5 -target $(TARGET) -o main.o


> make build_main

Will show bellow.

Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c main.swift -Xcc -working-directory -Xcc /Users/qihongye/Documents/BLOG/swift/BUILD_SEGFAULT -whole-module-optimization -O -enable-objc-interop -emit-module -emit-objc-header -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.0.sdk -module-name Main -target-sdk-version 14.0 -I/Users/qihongye/Documents/BLOG/swift/BUILD_SEGFAULT/Enum -F/Users/qihongye/Documents/BLOG/swift/BUILD_SEGFAULT/Enum -framework Enum -swift-version 5 -target x86_64-apple-ios14.0-simulator -o main.o

  1. Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
  2. Running pass 'Function Pass Manager' on module 'main.o'.
  3. Running pass 'X86 Assembly Printer' on function '@"$s4Main1ACACycfc"'
    0 swift 0x000000010ff5d865 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
    1 swift 0x000000010ff5c865 llvm::sys::RunSignalHandlers() + 85
    2 swift 0x000000010ff5de1f SignalHandler(int) + 111
    3 libsystem_platform.dylib 0x00007fff6ed1f5fd _sigtramp + 29
    4 libsystem_platform.dylib 0x00000001121a5380 _sigtramp + 18446603343255592352
    5 swift 0x000000010d1db78c (anonymous namespace)::X86MCCodeEmitter::encodeInstruction(llvm::MCInst const&, llvm::raw_ostream&, llvm::SmallVectorImplllvm::MCFixup&, llvm::MCSubtargetInfo const&) const + 204
    6 swift 0x000000010fcd6df0 (anonymous namespace)::MCMachOStreamer::EmitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) + 192
    7 swift 0x000000010fcdeabe llvm::MCObjectStreamer::EmitInstruction(llvm::MCInst const&, llvm::MCSubtargetInfo const&) + 302
    8 swift 0x000000010d15e8a3 llvm::X86AsmPrinter::EmitAndCountInstruction(llvm::MCInst&) + 51
    9 swift 0x000000010d15f7b4 llvm::X86AsmPrinter::EmitInstruction(llvm::MachineInstr const*) + 2836
    10 swift 0x000000010d59f56e llvm::AsmPrinter::EmitFunctionBody() + 6878
    11 swift 0x000000010cef4ae3 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) + 163
    12 swift 0x000000010e1da942 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 194
    13 swift 0x000000010fe29ced llvm::FPPassManager::runOnFunction(llvm::Function&) + 925
    14 swift 0x000000010fe2a753 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
    15 swift 0x000000010fe2ac1d llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1005
    16 swift 0x000000010be83300 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 6640
    17 swift 0x000000010bad50c0 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_deleteswift::SILModule >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 3904
    18 swift 0x000000010bac4ae0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 21152
    19 swift 0x000000010ba45c07 main + 1255
    20 libdyld.dylib 0x00007fff6eb26cc9 start + 1
    21 libdyld.dylib 0x000000000000001d start + 18446603338658976597
    make: *** [build_main_o] Segmentation fault: 11
@swift-ci
Copy link
Collaborator Author

Comment by Hongye Qi (JIRA)

`-Onone` or `-target arm64` can fix this, just because it not call `X86MCCodeEmitter::encodeInstruction`.

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 3, 2021

Comment by Hongye Qi (JIRA)

Can anyone help me?

@typesanitizer
Copy link

Hi, can you check with Xcode 12.5 beta 1 or with a recent trunk development snapshot from https://swift.org/download/ ? I think this problem should be fixed there.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants