When building my project with Xcode 12, Eureka fails to build with a Segmentation Fault: 11
error.
The error log begings like this:
1. Apple Swift version 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)
2. While evaluating request TypeCheckSourceFileRequest(source_file "<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift")
3. While evaluating request TypeCheckFunctionBodyUntilRequest(Eureka.(file).SelectableSectionType extension.selectedRows()@<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:76:17, )
4. While type-checking statement at [<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:76:51 - line:79:5] RangeText="{
let selectedRows: [BaseRow] = self.filter { $0 is SelectableRow && $0.baseValue != nil }
return selectedRows.map { $0 as! SelectableRow }
"
5. While type-checking declaration 0x7fd43d09ab50 (at <omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:77:9)
6. While type-checking expression at [<omitted>/Pods/Eureka/Source/Core/SelectableSection.swift:77:39 - line:77:96] RangeText="self.filter { $0 is SelectableRow && $0.baseValue != nil "
Seems llvm is having trouble understanding this part in SelectableSection.swift:
/**
Returns the selected rows of this section. Should be used if selectionType is MultipleSelection
*/
public func selectedRows() -> [SelectableRow] {
let selectedRows: [BaseRow] = self.filter { $0 is SelectableRow && $0.baseValue != nil }
return selectedRows.map { $0 as! SelectableRow }
}
I tried rewrite it with compactMap
or if let
but no luck.
Did anyone succeed building Eureka with Xcode 12? Thanks!
Environment:
Eureka 5.2.1
Xcode 12 beta 2
macOS 10.15.5
It's look like a problem with the semantics of the extension when you access to "self" into it.
open class Section { ... }
public protocol SelectableSectionType: Collection { ... }
extension SelectableSectionType where Self: Section {
public func selectedRows() -> [SelectableRow] {
let selectedRows: [BaseRow] = self.filter { $0 is SelectableRow && $0.baseValue != nil }
return selectedRows.map { $0 as! SelectableRow }
}
}
I think that, when _self_ is access there, the compiler doesn't know if _self_ is _Section_ (not an array) or _SelectableSectionType_ and then ... crash.
I don't know if this code could be replaced with:
public func selectedRows() -> [SelectableRow] {
return self.selectedRows().filter { $0.baseValue != nil }
}
and generate the same result (with it, this method compiles). Could anyone confirm that?
Thanks!
PD:
The prepare
method of this class needs the same replace when accessed to self
in this loop:
case let .singleSelection(enableDeselection):
s.forEach { // <--- Segmentation fault here
...
}
@daviwiki You are right, replacing that part with the code you provided actually fixed the error.
Though I'm still no sure calling its own selectedRows()
inside the selectedRows()
definition is safe.
Any way, it seems very likely to be a bug introduced into LLVM in Xcode 12 Beta 2. So let's hope someone there could notice and get it fixed.
@xiao99xiao lol, i'm so sorry, my bad. I was checking some combination and copy the wrong one 😅, this code probably generate and infinite recursion.
I want to write something like this:
public func selectedRows() -> [SelectableRow] {
let selectedRows: [BaseRow] = self.allRows.filter { $0 is SelectableRow && $0.baseValue != nil }
return selectedRows.map { $0 as! SelectableRow }
}
Hi, Is there any workaround for fixing it?
Thanks!
Using allRows
as mentioned by @daviwiki avoids the crash. However it is not the same behavior as before: currently only visible rows are filtered when doing a self.filter
. For most cases that should be fine though.
Hoping for Apple to fix the compiler.
Another possibility is moving the functions func selectedRows() -> [SelectableRow]
and func prepare(selectableRows rows: [BaseRow])
to the class implementation. The crash only appears in extensions
Thanks! ❤️, we will try with this fix until Apple solves this compiler issue.
I also see this crash in Xcode 12 beta 2. I hope this gets fixed in the next Xcode release if we all file a bug report to Apple.
The problem is also present on Xcode 11.6 released on 15-jul
Works for me in 11.6 (11E708), just not 12 b2.
Present in beta 3 unfortunately. Feels like moving on a fix in the framework might be the best way to proceed. Thoughts?
I've submitted a workaround PR for this issue, if anyone's interested:
Works a dream, thanks @mattgallagher! Hope this gets approved soon...
Hey all, #2061 has been merged into an xcode12
branch. The error is fixed there. If Apple doesn't fix this error then we will merge this into master
so for this moment, podfile should be
pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git', :branch => 'xcode12'
FYI - still an issue in today's Beta 5 release.
FYI - still an issue in today's Beta 5 release.
Really? Interesting, the issue has gone for me.
Still having the error on Beta 5. Clean build + Clean derived data
Thanks for reporting
Still having the error on Beta 5. Clean build + Clean derived data
same
For me it works with Xcode 12 beta 5 when I use the xcode12
branch
Still an issue in Beta 6 😢
Xcode 12 Beta 6, same error. Any updates on it?
Hey all, #2061 has been merged into an
xcode12
branch. The error is fixed there. If Apple doesn't fix this error then we will merge this into master
感谢! 已经解决了我的2个编译错误!!!
Error1: Command CompileSwift failed with a nonzero exit code
Error2: Segmentation fault: 11
if you are using Cocoapods
this worked for me
pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git', :branch => 'xcode12'
branch xcode12 worked partially. It messes up when extending with generics because of the new "AnyObject" protocol on that branch
Yes, this is a huge blocker for us too
Hi @jlcvp and @txaiwieser could you be more specific with the issues you are facing with the xcode12
branch? What error or limitation are you getting?
@mats-claassen I have a func that constructs a custom Row depending on the type received. This func uses generics in a fairly complex way, like this:
func myCustomRow<ACell: Cell<myCellViewModel>, ARow: Row<ACell>> (obj: ARow.Type, value: CustomCellValue, section: Section) where ARow: RowType, ACell: CellType {
There is a bug report for this issue here: https://bugs.swift.org/browse/SR-13170. You can vote it up so that it might get more attention.
@jlcvp can you share the stacktrace and error message for your issue?
Hi @mats-claassen, I fully understand all the moving parts here, and that this may be an unreasonable question! But given the announcement that iOS 14 will be released tomorrow, could you please share your thoughts on the timing of this fix? Do you plan to have a compatible release ASAP, or do you plan to hold off until there is more clarity on reported issues, such as @jlcvp's? That information would help me, and hopefully others, who plan to release iOS 14 updates for their apps ASAP. Thank you!
It seems the issue will be there in the stable release so I will merge and try to create a release today. That being said, I still don't know more details about the issue @jlcvp mentioned above and whether this is something we can fix with another workaround.
Eureka 5.3.0 released!
Closing this issue as fixed. If there is any unresolved issue please open a new one
I'm updating today Eureka to 5.3.0 with cocoapods in xCode 12, and the segmentation fault persist.
Are you sure you are using 5.3.0? Have you done a clean and build? Do you have additional code that might be causing it? The same line of code should not provoke a segmentation fault in the latest version.
A stacktrace would be helpful as well
yep sorry, solved. I've some other pods made by Eureka's community about rich texts and address text that requires lower version of Eureka.
Removing them upgrade Eureka to 5.3.0 and problem has been solved.
unfortunately, the issue still exists with Xcode 12
Sow could we merge the fix to the main branch
rather than 'xcode12' branch
pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git', :branch => 'xcode12'
it's already merged on the 5.3.0
After using pod 'Eureka', :git => 'https://github.com/xmartlabs/Eureka.git', :branch => 'xcode12'
still there is error Segmentation fault: 11 in xcode 12
@ShoaibPathan You should use version 5.3.0. Also try doing a clean and build
Still seems to be an issue for me using version 5.3.1
Upgrading to 5.3.1, along with a clean build solved it for me with XCode 12.0.1.
Most helpful comment
Eureka 5.3.0 released!