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

run().read()'ing particularly long outputs causes a hang #15

Closed
master-nevi opened this issue Mar 2, 2016 · 2 comments
Closed

run().read()'ing particularly long outputs causes a hang #15

master-nevi opened this issue Mar 2, 2016 · 2 comments

Comments

@master-nevi
Copy link

Basically NSTask.waitUntilExit() never returns for some reason. Easy to reproduce by calling cat <some_large_text_file>.txt

screen shot 2016-03-02 at 3 09 22 pm

@kareman
Copy link
Owner

kareman commented Mar 3, 2016

Hi, judging by the screenshot it seems like you're using version 1. I get the same error in the latest version (2):

run("cat","longtext.txt")

This function does indeed call task.waitUntilExit(). This however does not and works fine:

runAsync("cat","longtext.txt").stdout.read()

@kareman kareman closed this as completed in b0e3796 Mar 3, 2016
@kareman
Copy link
Owner

kareman commented Mar 3, 2016

Postponing task.waitUntilExit() until after reading all of the output fixed the problem. I still want to wait until the task has finished just in case it does some work after closing its standard output.

@master-nevi and thanks for reporting this. Please let me know if this fixes the problem for you.

kareman added a commit that referenced this issue 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

No branches or pull requests

2 participants