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-9614] Segmentation fault: 11 at swift::ASTVisitor... #52060
Comments
Comment by Michael Ozeryansky (JIRA) Also, I'm getting Segmentation Faults in 2 files. One file I did not touch. Each file defines a class which is not used by each other, so they're mostly unrelated. |
Comment by Michael Ozeryansky (JIRA) It seems the issue came from defining an extension on my protocol which implements a function. |
Comment by Michael Ozeryansky (JIRA) I tracked it down. I had the instance variable typed to my protocol as an optional. I wasn't defaulting the nullable value, and when I added a default value everything worked. old: self.x = myProtocolInstance?.func() <= Segment Fault |
Do you have a self-contained reproducer for this? Or can you share your full project in the bad state? (If not here, then at https://bugreport.apple.com.) cc @xedin |
Comment by Michael Ozeryansky (JIRA) Unfortunately, I don't have a reproducing crashing code, after resolving the crash I've moved on. I tried creating a sample project but I can't reproduce. My project is made up of external and local cocoapods. The issue occurred within a local pod framework. I don't believe this is an issue with Cocoapods just noting that since they setup the framework configuration. This framework is included by another framework, and that framework is included by the main app. In general, I won't be able to share my entire project, but is there a way to enable more logging or something else I can provide in future bugs? |
If you can't include your project maybe you could at least clarify what `self` and `x` are to give us some starting point?... |
Comment by Michael Ozeryansky (JIRA) self is referencing a class which is a subclass of a subclass of Operation. And x is an instance variable with the type [[UInt8]].
{{ bar(nonOptional: x)}}
{{ func bar(nonOptional: [[UInt8]])}}{ {{ someOtherFunction(nonOptional)}} } {{}}} Although, this example (with and without the "— ") doesn't cause the crash. At the time I filed the bug I did not realize the returned value was optional and did not have the nil coalescing. Adding " [[Uint8]]()" resolved the crash. In my attempted sample project, Xcode says the value is optional as expected. We have a fairly large project made up of frameworks including each other frameworks. My indexing seems to be fairly slow, so there must be something there with the type resolution. |
mozeryansky (JIRA User) Does `function()` return `[[UInt8]]?` or is it generic? |
Comment by Michael Ozeryansky (JIRA) It returns `[[UInt8]]`, non-optional. And I think I had `let x = ...` so it must have been inferred by the return type. Sorry for not having a sample, thanks for trying to figure this out. |
I wonder why would you need a `??` with default if neither `x` nor left-hand side was an optional? |
Ah wait I missed that there was optional chaining going on. |
Comment by Michael Ozeryansky (JIRA) Yeah, I missed that too. Wasn't until I added "?? [[UInt8]]()" did it go away. But even removing it now doesn't cause the crash. |
Environment
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Xcode 10.1 (10B61)
Additional Detail from JIRA
md5: 4eed5652c524aabc20a170c9ec341802
Issue Description:
Aftering adding an import I now get Segmentation Faults. Clearing derived data / etc doesn't work. I've imported this module before in other places throughout my app.
0 swift 0x000000010bc1959a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010bc18d4e SignalHandler(int) + 302
2 libsystem_platform.dylib 0x00007fff7b8d2b3d _sigtramp + 29
3 libsystem_platform.dylib 0x000000010d1f4000 _sigtramp + 2442269920
4 swift 0x0000000109323e4c swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 76
5 swift 0x0000000109323f07 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 263
6 swift 0x0000000109323e85 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 133
7 swift 0x0000000108eb70db swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*) + 827
8 swift 0x0000000108f01198 swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 9112
9 swift 0x0000000108fb92f4 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 52
10 swift 0x0000000108fb9a17 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1207
11 swift 0x0000000108e91d4c (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*, bool) + 1516
12 swift 0x0000000108e8f577 (anonymous namespace)::FailureDiagnosis::typeCheckArbitrarySubExprIndependently(swift::Expr*, swift::OptionSet<TCCFlags, unsigned int>) + 839
13 swift 0x0000000108e81fba swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 3850
14 swift 0x0000000108eb449f swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 6207
15 swift 0x0000000108fb933a swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 122
16 swift 0x0000000108fb9a17 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1207
17 swift 0x000000010905189c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 12044
18 swift 0x000000010904daae swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 1294
19 swift 0x0000000109053358 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 888
20 swift 0x0000000109079f03 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2515
21 swift 0x0000000108cb3f05 swift::CompilerInstance::performSema() + 4949
22 swift 0x0000000107e9f50b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
23 swift 0x0000000107e9bd35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
24 swift 0x0000000107e41965 main + 1349
25 libdyld.dylib 0x00007fff7b6e908d start + 1
error: Segmentation fault: 11
The text was updated successfully, but these errors were encountered: