Flix icon indicating copy to clipboard operation
Flix copied to clipboard

Segmentation fault: 11 While emitting IR SIL function ...

Open DianQK opened this issue 5 years ago • 1 comments

Maybe you will find Segmentation fault: 11 While emitting IR SIL function ... error info when use AnimatableCollectionViewProvider. This look like Swift bug.

This issue will closed when this error go away.

This code will cause Segmentation fault: 11:

class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
    func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
    }
    func createValues() -> Observable<[Value]> {
        return Observable.empty()
    }
    typealias Cell = RadioCollectionViewCell
    typealias Value = Option
}

There are some workaround methods:

add createAnimatableNodes:

class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
    func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
    }
    func createValues() -> Observable<[Value]> {
        return Observable.empty()
    }
    typealias Cell = RadioCollectionViewCell
    typealias Value = Option
    func createAnimatableNodes() -> Observable<[IdentifiableNode]> {
        let providerIdentity = self._flix_identity
        return createValues()
            .map { $0.map { IdentifiableNode(providerIdentity: providerIdentity, valueNode: $0) } }
    }
}

or add a model to warp this Option:

struct SegmentationFault11Warp<Value: Equatable & StringIdentifiableType>: Equatable & StringIdentifiableType {
    var identity: String {
        return value.identity
    }
    let value: Value
}

class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
    func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
    }
    func createValues() -> Observable<[Value]> {
        return Observable.empty()
    }
    typealias Cell = RadioCollectionViewCell
    typealias Value = SegmentationFault11Warp<Option>
}

DianQK avatar Sep 20 '19 09:09 DianQK

This very helpful !

@DianQK wondering how to explain the crash and your advised ways of workaround ?

10000TB avatar Sep 20 '19 15:09 10000TB