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-5187] Swiftc 4-beta crashes when compiling Freddy (fork) in release-mode #47763

Closed
swift-ci opened this issue Jun 11, 2017 · 3 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 4.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5187
Radar rdar://problem/32713742
Original Reporter helge (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

swift --version
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, CompilerCrash, OptimizedOnly
Assignee @eeckstein
Priority Medium

md5: 06e38b77a7cb0e9ac156df0212442f1d

Issue Description:

git clone https://github.com/modswift/Freddy.git Freddy-https
cd Freddy-https
swift build -c release

gives

Compile Swift Module 'Freddy' (10 sources)
0  swift                    0x0000000109cf43aa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000109cf37e6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffa77afefa _sigtramp + 26
3  libsystem_platform.dylib 0x000000010adada00 _sigtramp + 1667226400
4  swift                    0x0000000106709493 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*) + 1267
5  swift                    0x00000001067b4251 emitUnaryRefCountCall(swift::irgen::IRGenFunction&, llvm::Constant*, llvm::Value*) + 353
6  swift                    0x000000010685ca3c swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 32364
7  swift                    0x00000001068523f1 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9233
8  swift                    0x0000000106764290 swift::irgen::IRGenerator::emitLazyDefinitions() + 6560
9  swift                    0x00000001068356aa swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, llvm::GlobalVariable**) + 2410
10 swift                    0x00000001066c6d41 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 16849
11 swift                    0x00000001066c1304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
12 swift                    0x0000000106677728 main + 12248
13 libdyld.dylib            0x00007fffa754c515 start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Volumes/Sources/Swift/Freddy-https/Sources/JSON.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONDecodable.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONEncodable.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONEncodingDetector.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONLiteralConvertible.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONOptional.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONParser.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONParsing.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONSerializing.swift /Volumes/Sources/Swift/Freddy-https/Sources/JSONSubscripting.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Volumes/Sources/Swift/Freddy-https/.build/release -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -module-cache-path /Volumes/Sources/Swift/Freddy-https/.build/release/ModuleCache -swift-version 3 -D SWIFT_PACKAGE -emit-module-doc-path /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.swiftdoc -O -parse-as-library -module-name Freddy -emit-module-path /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.swiftmodule -emit-dependencies-path /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/Freddy.d -num-threads 8 -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSON.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONDecodable.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONEncodable.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONEncodingDetector.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONLiteralConvertible.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONOptional.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONParser.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONParsing.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONSerializing.swift.o -o /Volumes/Sources/Swift/Freddy-https/.build/release/Freddy.build/JSONSubscripting.swift.o 
1.  While emitting IR SIL function "@_T06Freddy10JSONParserV19decodeIntegralValue33_CA3C9A2D4E0127F7667B225FFBCE6A53LLAA4JSONOAA12NumberParserAELLVKF".
 for 'decodeIntegralValue' at /Volumes/Sources/Swift/Freddy-https/Sources/JSONParser.swift:441:22
<unknown>:0: error: unable to execute command: Bus error: 10
<unknown>:0: error: compile command failed due to signal 10 (use -v to see invocation)
error: terminated(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Volumes/Sources/Swift/Freddy-https/.build/release.yaml
@belkadan
Copy link
Contributor

@swift-ci create

@eeckstein
Copy link
Member

The problem is that when building in release mode, the function JSONParser.decodeIntegralValue() contains an infinite loop.
This is because in release mode the assertFailure is a no-op

{{[...]
case .postDecimalDigits, .exponentSign, .exponentDigits:
assertionFailure("Invalid internal state while parsing number")
[...]
}}

If one of these cases are hit, the outer while-loop ends up in an infinite loop.

This is clearly a compiler bug which needs to be fixed. The compiler should be able to handle infinite loops.

As a workaround (and I would even say: a safer way to handle these case values) you can replace this assertFailure with a fatalError.

@eeckstein
Copy link
Member

Fixed on master in #10549

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation regression swift 4.0
Projects
None yet
Development

No branches or pull requests

4 participants