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-10343] Compiler crasher, possibly related to SE-0229 and arrays. #52743

Closed
jepers opened this issue Apr 9, 2019 · 5 comments
Closed

[SR-10343] Compiler crasher, possibly related to SE-0229 and arrays. #52743

jepers opened this issue Apr 9, 2019 · 5 comments
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

Comments

@jepers
Copy link

jepers commented Apr 9, 2019

Previous ID SR-10343
Radar None
Original Reporter @jepers
Type Bug
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, OptimizedOnly
Assignee None
Priority Medium

md5: a27aa3761a87b6b976b7619da38b5ed3

Issue Description:

The following program compiles without `-O` but crashes compiler with `-O`.

Not sure if it is a regression from (default toolchain of) Xcode 10.1 to Xcode 10.2, I only have Xcode 10.2 at hand.
More details here:
https://forums.swift.org/t/is-this-a-known-xcode-10-2-regression/22863

import simd

struct Curve {
    var p0, p1, p2, p3: float2
    var points: [float2] { return [p0, p1, p2, p3 ] }
    init(_ p0: float2, _ p3: float2) {
        (self.p0, self.p1, self.p2, self.p3) = (p0, p0, p3, p3)
    }
}

struct Polycurve {
    var points: [float2]
    init(_ points: [float2]) { self.points = points }
}

func test() {
    let c = Curve(float2(0, 0), float2(1, 1))
    let pc = Polycurve(c.points + [c.points[0]]) // <--- This crashes the compiler (compiling with -O).
    //let pc = Polycurve(c.points + [c.p0]) // <-- Note that this reformulation does not crash the compiler.
    print(pc)
}
test()

Works without -O:

$ swiftc --version
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
$ swiftc test.swift
$ ./test
Polycurve(points: [SIMD2<Float>(0.0, 0.0), SIMD2<Float>(0.0, 0.0), SIMD2<Float>(1.0, 1.0), SIMD2<Float>(1.0, 1.0), SIMD2<Float>(0.0, 0.0)])

Crashes compiler with -O:

$ swiftc -O test.swift
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-darwin18.5.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -O -color-diagnostics -module-name test -o /var/folders/50/br4kxvjd0t551h0fmtrzkwdw0000gn/T/test-ae77e8.o 
1.  While running pass #&#8203;7084 SILFunctionTransform "DCE" on SILFunction "@$s4testAAyyF".
 for 'test()' (at test.swift:16:1)
0  swift                    0x000000010e63bee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010e63b6bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff5b263b5d _sigtramp + 29
3  libsystem_platform.dylib 0x000000010fbcfe00 _sigtramp + 3029779136
4  swift                    0x000000010b309a00 (anonymous namespace)::DCE::markControllingTerminatorsLive(swift::SILBasicBlock*) + 816
5  swift                    0x000000010b3092e1 (anonymous namespace)::DCE::markValueLive(swift::SILNode*) + 417
6  swift                    0x000000010b306c2c (anonymous namespace)::DCE::run() + 2940
7  swift                    0x000000010b292823 swift::SILPassManager::execute() + 4627
8  swift                    0x000000010a4a0408 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 50264
9  swift                    0x000000010a4906de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
10 swift                    0x000000010a42e7be main + 1246
11 libdyld.dylib            0x00007fff5b07e3d5 start + 1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)

Note that the stack dump is a different one maybe 5% of repeated swiftc -O test.swift commands (see forum post for details).

@weissi
Copy link
Member

weissi commented Apr 9, 2019

not a regression from 4.2

4.2

$ jw-swift-4.2 swiftc -O /tmp/test.swift
Assertion failed: (!KeyInfoT::isEqual(Val, EmptyKey) && !KeyInfoT::isEqual(Val, TombstoneKey) && "Empty/Tombstone value shouldn't be inserted into map!"), function LookupBucketFor, file /Users/buildnode/jenkins/workspace/oss-swift-4.2-package-osx/llvm/include/llvm/ADT/DenseMap.h, line 589.
0  swift                    0x000000010ef217b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010ef20a17 llvm::sys::RunSignalHandlers() + 39
2  swift                    0x000000010ef21e32 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff65365b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00000000000038b8 _sigtramp + 2596920696
5  libsystem_c.dylib        0x00007fff652256a6 abort + 127
6  libsystem_c.dylib        0x00007fff651ee20d basename_r + 0
7  swift                    0x000000010bfb8985 swift::TypeExpansionAnalysis::getTypeExpansion(swift::SILType, swift::SILModule*) + 629
8  swift                    0x000000010c03c77d swift::LSValue::expand(swift::SILValue, swift::SILModule*, llvm::SmallVector<swift::LSValue, 8u>&, swift::TypeExpansionAnalysis*) + 45
9  swift                    0x000000010c1972ea (anonymous namespace)::BlockState::processStoreInst((anonymous namespace)::RLEContext&, swift::StoreInst*, RLEKind) + 1930
10 swift                    0x000000010c19400b (anonymous namespace)::RedundantLoadElimination::run() + 7035
11 swift                    0x000000010c092da1 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1441
12 swift                    0x000000010c093d63 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1299
13 swift                    0x000000010c094a54 swift::SILPassManager::execute() + 644
14 swift                    0x000000010b8bd6ab swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
15 swift                    0x000000010c09cb55 swift::runSILOptimizationPasses(swift::SILModule&) + 117
16 swift                    0x000000010b755fa0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13424
17 swift                    0x000000010b751b22 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2946
18 swift                    0x000000010b70c908 main + 1128
19 libdyld.dylib            0x00007fff651803d5 start + 1
20 libdyld.dylib            0x0000000000000010 start + 2598894652
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-4.2-RELEASE.xctoolchain/usr/bin/swift -frontend -c -primary-file /tmp/test.swift -target x86_64-apple-darwin18.5.0 -enable-objc-interop -sdk ... -O -color-diagnostics -module-name test -o /var/folders/lj/qfjqv9_x6b972r7l6f49lvmh0000gn/T/test-a1206f.o 
1.  While running pass #&#8203;6017 SILFunctionTransform "RedundantLoadElimination" on SILFunction "@$S4testAAyyF".
 for 'test()' at /tmp/test.swift:16:1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
-254- johannes:~/devel/swift-nio (master)

5.0

$ jw-swift-5.0 swiftc -O /tmp/test.swift
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.0-RELEASE.xctoolchain/usr/bin/swift -frontend -c -primary-file /tmp/test.swift -target x86_64-apple-darwin18.5.0 -enable-objc-interop -sdk ... -O -color-diagnostics -module-name test -o /var/folders/lj/qfjqv9_x6b972r7l6f49lvmh0000gn/T/test-d08141.o 
1.  While running pass #&#8203;7081 SILFunctionTransform "EarlyRedundantLoadElimination" on SILFunction "@$s4testAAyyF".
 for 'test()' (at /tmp/test.swift:16:1)
0  swift                    0x000000010a854245 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010a8534e5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010a854832 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff65365b5d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 2596906176
5  swift                    0x0000000107acebd6 swift::SILType::isAddressOnly(swift::SILModule&) const + 22
6  swift                    0x000000010795a0a9 swift::shouldExpand(swift::SILModule&, swift::SILType) + 25
7  swift                    0x0000000107668787 swift::TypeExpansionAnalysis::getTypeExpansion(swift::SILType, swift::SILModule*) + 199
8  swift                    0x000000010794ef1a swift::LSValue::expand(swift::SILValue, swift::SILModule*, llvm::SmallVector<swift::LSValue, 8u>&, swift::TypeExpansionAnalysis*) + 42
9  swift                    0x000000010786e783 (anonymous namespace)::BlockState::processStoreInst((anonymous namespace)::RLEContext&, swift::StoreInst*, RLEKind) + 2099
10 swift                    0x000000010786b32b (anonymous namespace)::RedundantLoadElimination::run() + 7019
11 swift                    0x00000001077ba763 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1619
12 swift                    0x00000001077bb593 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1299
13 swift                    0x00000001077bc5af swift::SILPassManager::execute() + 607
14 swift                    0x0000000106de831b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
15 swift                    0x00000001077c5455 swift::runSILOptimizationPasses(swift::SILModule&) + 117
16 swift                    0x0000000106c96934 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 11348
17 swift                    0x0000000106c92c78 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3016
18 swift                    0x0000000106c44d52 main + 690
19 libdyld.dylib            0x00007fff651803d5 start + 1
20 libdyld.dylib            0x0000000000000010 start + 2598894652
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)

@belkadan
Copy link
Contributor

belkadan commented Apr 9, 2019

…and seems to be fixed on master. @eeckstein, any idea what would have changed?

@eeckstein
Copy link
Member

This looks like a dup of SR-10003

@jepers
Copy link
Author

jepers commented Apr 12, 2019

As mentioned by @belkadan, I can verify that this seems to be fixed in
swift-DEVELOPMENT-SNAPSHOT-2019-04-10-a-osx.pkg

Should I close this or leave it open for further investigation or as a reminder to add tests for it or something?

@eeckstein
Copy link
Member

As you verified that it's fixed, we can close it.

@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
Projects
None yet
Development

No branches or pull requests

5 participants