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

Update to Swift 1.2 with workaround for compiler crash #9

Merged
merged 2 commits into from
Feb 13, 2015
Merged

Update to Swift 1.2 with workaround for compiler crash #9

merged 2 commits into from
Feb 13, 2015

Conversation

beltex
Copy link
Contributor

@beltex beltex commented Feb 13, 2015

Hi @kareman! I saw your comment about the compiler crash, so I took a look! Seems like its the workdirectory property with it’s getter thats causing the compiler crash. I’ve submitted it to the swift-compiler-crashes project.

As a workaround, made workdirectory a struct with static get() and set() functions. All tests pass except for a few in Stream_Tests.swift, which as far as I can tell is unrelated to the workdirectory change, but certainly new as a result of Xcode 6.3.

These hang at runtime:

  • testCustomStream
  • testStreamFromArray

While these crash at runtime:

  • testSequenceOfStreamsToStream
  • testChainWithSequenceOfStreamsPrintedToStream
  • testChainWithSequenceOfStringsPrintedToStream

- countElements() renamed to count()

Via release notes
- "The notions of guaranteed conversion and “forced failable” conversion are now
   separated into two operators. Forced failable conversion now uses the as!
   operator. The ! makes it clear to readers of code that the cast may fail and
   produce a runtime error. The “as” operator remains for upcasts
   (e.g. “someDerivedValue as Base”) and type annotations (“0 as Int8”) which
   are guaranteed to never fail."
- "The implicit conversions from bridged Objective-C classes
   (NSString/NSArray/NSDictionary) to their corresponding Swift value types
   (String/Array/Dictionary) have been removed, making the Swift type system
   simpler and more predictable."
- "The @autoclosure attribute is now an attribute on a parameter, not an
   attribute on the parameter’s type."
kareman added a commit that referenced this pull request Feb 13, 2015
To work around compiler crash in Xcode 6.3 beta 1 on public global
variables with default value. Wanted to move tempdirectory there too
but extensions can’t have stored properties.
Close #8.
Close #9 (pull request from @beltex)
@kareman kareman merged commit e8333f2 into kareman:master Feb 13, 2015
@kareman
Copy link
Owner

kareman commented Feb 14, 2015

@beltex 👍 excellent work, I was dreading having to decipher another segmentation fault 11 compiler crash.

Instead of moving it to a struct I turned workdirectoryinto an extension on NSFilemanager, so you can go File.workdirectory = ... etc. I really want to move tempdirectory there too for consistency but you can't store anything in extensions. I will probably move workdirectory back to the global level when this compiler bug has been fixed.

I disabled the 3 unit tests that crash at runtime until I can find a fix for them. The 2 tests you mention hang at runtime, plus a couple more, only hang when run individually. When running all unit tests at once they work fine. Weird.

@beltex beltex deleted the swift1.2 branch February 14, 2015 02:14
@beltex
Copy link
Contributor Author

beltex commented Feb 14, 2015

np! :)

Nice, yeah thats better than the struct, maintains the original usage style.

Cool, didn't know you could disable them like that! And strange indeed with the hangs.

@beltex
Copy link
Contributor Author

beltex commented Feb 27, 2015

Good news, looks like this compiler bug has been fixed in Xcode 6.3 Beta 2 :)

No luck on the tests though.

@kareman
Copy link
Owner

kareman commented Feb 27, 2015

Indeed, thanks for letting me know. I reverted the changes to workdirectory here: f76c81e

@beltex
Copy link
Contributor Author

beltex commented Feb 27, 2015

Nice, np! :)

kareman added a commit that referenced this pull request Apr 27, 2017
Now I vaguely recall it was there for a reason.

```
$ swift build
Compile Swift Module 'SwiftShell' (9 sources)
swift: /home/buildnode/disk2/workspace/oss-swift-3.1-package-linux-ubuntu-14_04/swift/lib/Sema/CSApply.cpp:5990: swift::Expr *(anonymous namespace)::ExprRewriter::coerceObjectArgumentToType(swift::Expr *, swift::Type, swift::ValueDecl *, swift::AccessSemantics, swift::constraints::ConstraintLocatorBuilder): Assertion `fromType->is<LValueType>() && "Can only convert lvalues to inout"' failed.
#0 0x000000000335ffe8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x335ffe8)
#1 0x0000000003360b86 SignalHandler(int) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x3360b86)
#2 0x00007f239201c330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x00007f2390a07c37 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36c37)
#4 0x00007f2390a0b028 abort (/lib/x86_64-linux-gnu/libc.so.6+0x3a028)
#5 0x00007f2390a00bf6 (/lib/x86_64-linux-gnu/libc.so.6+0x2fbf6)
#6 0x00007f2390a00ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#7 0x00000000010a306a (anonymous namespace)::ExprRewriter::coerceObjectArgumentToType(swift::Expr*, swift::Type, swift::ValueDecl*, swift::AccessSemantics, swift::constraints::ConstraintLocatorBuilder) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x10a306a)
#8 0x000000000109b0cc (anonymous namespace)::ExprRewriter::buildMemberRef(swift::Expr*, swift::Type, swift::SourceLoc, swift::ValueDecl*, swift::DeclNameLoc, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder, bool, swift::FunctionRefKind, swift::AccessSemantics, bool) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x109b0cc)
#9 0x00000000010a8c3f swift::ASTVisitor<(anonymous namespace)::ExprRewriter, swift::Expr*, void, void, void, void, void>::visit(swift::Expr*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x10a8c3f)
#10 0x0000000001099314 (anonymous namespace)::ExprRewriter::walkToExprPost(swift::Expr*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x1099314)
#11 0x00000000010b11b1 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x10b11b1)
#12 0x000000000128901c (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x128901c)
#13 0x000000000128303b swift::Expr::walk(swift::ASTWalker&) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x128303b)
#14 0x00000000010960f2 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x10960f2)
#15 0x00000000011604ff swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x11604ff)
#16 0x000000000107af20 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x107af20)
#17 0x000000000107b219 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x107b219)
#18 0x000000000107ae4c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x107ae4c)
#19 0x0000000001079ad5 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x1079ad5)
#20 0x0000000001078dad swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x1078dad)
#21 0x0000000001078c05 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x1078c05)
#22 0x000000000107981c swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x107981c)
#23 0x000000000108fc08 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x108fc08)
#24 0x00000000010908a1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x10908a1)
#25 0x0000000000e0fe4a swift::CompilerInstance::performSema() (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0xe0fe4a)
#26 0x0000000000475eed swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x475eed)
#27 0x000000000043bbe4 main (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x43bbe4)
#28 0x00007f23909f2f45 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f45)
#29 0x00000000004395a0 _start (/home/travis/.swiftenv/versions/3.1/usr/bin/swift+0x4395a0)
Stack dump:
0.	Program arguments: /home/travis/.swiftenv/versions/3.1/usr/bin/swift -frontend -c /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/FileHandle.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/String.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Bash.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Context.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Files.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Command.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/General/Array.swift -primary-file /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Stream/Stream.swift /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Stream/Lazy-split.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/travis/build/kareman/SwiftShell/.build/debug -enable-testing -g -module-cache-path /home/travis/build/kareman/SwiftShell/.build/debug/ModuleCache -D SWIFT_PACKAGE -emit-module-doc-path /home/travis/build/kareman/SwiftShell/.build/debug/SwiftShell.build/Stream~partial.swiftdoc -Onone -parse-as-library -module-name SwiftShell -emit-module-path /home/travis/build/kareman/SwiftShell/.build/debug/SwiftShell.build/Stream~partial.swiftmodule -emit-dependencies-path /home/travis/build/kareman/SwiftShell/.build/debug/SwiftShell.build/Stream.d -emit-reference-dependencies-path /home/travis/build/kareman/SwiftShell/.build/debug/SwiftShell.build/Stream.swiftdeps -num-threads 8 -o /home/travis/build/kareman/SwiftShell/.build/debug/SwiftShell.build/Stream/Stream.swift.o
1.	While type-checking 'write' at /home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Stream/Stream.swift:89:9
2.	While type-checking expression at [/home/travis/build/kareman/SwiftShell/Sources/SwiftShell/Stream/Stream.swift:90:38 - line:90:55] RangeText="target.write(text)"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants