Segmentation fault: 11 in Xcode 10 beta

Hello,


I'm trying to build my app using Xcode 10 beta - but I get an error wich I don't get on the previous versions. Any idea of what it could be?


While silgen emitConstructor SIL function "@$S14PROJECT25SBMonitoredVehicleJourneyV12directionRef04lineG017publishedLineName9monitored0L4Call15monitoringError24originAimedDepartureTime011destinationq7ArrivalS05delay08courseOfeG00pG00pK00tG00tK005routeG015vehicleLocation0Z4Mode0zG0AcA011SBDirectionG0OSg_SSSgAYSbAA0cM0VAA012SBMonitoringO0OSgA9yA17SBVehicleLocationVSgAA13SBVehicleModeOAYtcfC".
for 'init(directionRef:lineRef:publishedLineName:monitored:monitoredCall:monitoringError:originAimedDepartureTime:destinationAimedArrivalTime:delay:courseOfJourneyRef:originRef:originName:destinationRef:destinationName:routeRef:vehicleLocation:vehicleMode:vehicleRef:)' at /Users/name/Developer/PROJECT/PROJECT/Models/SBMonitoredVehicleJourney.swift:11:8
error: Segmentation fault: 11


struct SBMonitoredVehicleJourney: Equatable, Codable {   
    let directionRef: SBDirectionRef?
    /// Identifies the Line.
    let lineRef: String?
    /// Name or Number by which the line is known to the public.
    let publishedLineName: String?
    /// Whether there is real-time information available for journey; if not present, not known.
    let monitored: Bool
    let monitoredCall: SBMonitoredCall
    let monitoringError: SBMonitoringError?
    let originAimedDepartureTime, destinationAimedArrivalTime, delay, courseOfJourneyRef: String?
    let originRef, originName, destinationRef, destinationName: String?
    /// Identifier of Route that Journey follows.
    let routeRef: String?
    let vehicleLocation: SBVehicleLocation?
    let vehicleMode: SBVehicleMode
    /// Reference to a vehicle
    let vehicleRef: String?
    
    lazy var departureStatus: SBDepartureStatus = {
        if delay != nil {
            let startDate = Date()
            let components = NSDateComponents.duration(from: delay!)
            let endDate = NSCalendar.current.date(byAdding: components as DateComponents, to: startDate)
            
            if let timeInterval = endDate?.timeIntervalSince(startDate) {
                
                switch timeInterval {
                case ...(-60): return .early
                case 0...120: return .ontime
                case 120...: return .delayed
                default: return .noreport
                }
            }
        }
        
        return .noreport
    }()
    
    enum CodingKeys: String, CodingKey {
        case courseOfJourneyRef = "CourseOfJourneyRef"
        case delay = "Delay"
        case destinationAimedArrivalTime = "DestinationAimedArrivalTime"
        case destinationName = "DestinationName"
        case destinationRef = "DestinationRef"
        case directionRef = "DirectionRef"
        case lineRef = "LineRef"
        case monitored = "Monitored"
        case monitoredCall = "MonitoredCall"
        case monitoringError = "MonitoringError"
        case originAimedDepartureTime = "OriginAimedDepartureTime"
        case originName = "OriginName"
        case originRef = "OriginRef"
        case publishedLineName = "PublishedLineName"
        case routeRef = "RouteRef"
        case vehicleLocation = "VehicleLocation"
        case vehicleMode = "VehicleMode"
        case vehicleRef = "VehicleRef"
    }
}
Answered by espen in 315735022

Found the problem - it was in another class:


This was causing the isse:

Cache.imageOfCityBikeAnnotationIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .tile)

This fixed it:

Cache.imageOfCityBikeAnnotationIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .tile)

Did you run all possible sanitizers ? Maybe you have a well hidden problem in code.

Accepted Answer

Found the problem - it was in another class:


This was causing the isse:

Cache.imageOfCityBikeAnnotationIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .tile)

This fixed it:

Cache.imageOfCityBikeAnnotationIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .tile)

Ran into a segmentation fault. Happened after I was modifying the following line and was not obvious I was missing a last parentheses.

let blockW = min(geometry.size.width, 0.7 * (geometry.size.height + 10)

Surprising that I couldn't have gotten a friendlier error. This was with XCode 13.4.1.

However, when I tried to make a minimal simple program to submit as a bug report, I got useful errors such as: Use of local variable 'blockW' before its declaration. But could turn on/off segmentation problem easily when the statement was in my full app.

Segmentation fault: 11 in Xcode 10 beta
 
 
Q