uraimo / buildSwiftOnARM

All you need to build Swift on a RaspberryPi or other ARM boards, updated to Swift 5.1.5
489 stars 37 forks source link

[arm32][4.1.1][Foundation]String(contentsOfFile:) crash #8

Closed uraimo closed 6 years ago

uraimo commented 6 years ago

Sample:

import Foundation

if let str = try? String(contentsOfFile: "testfile") {
    print(str)
}

On Swift 3.1.1: Similar error Temporary "Workaround":

+++ swift-corelibs-foundation/CoreFoundation/Base.subproj/CFRuntime.c
CF_CROSS_PLATFORM_EXPORT void _CFDeinit(CFTypeRef cf) {
    __CFInfoType info = atomic_load(&(((CFRuntimeBase *)cf)->_cfinfoa));
     CFTypeID typeID = __CFTypeIDFromInfo(info);
     +    if (typeID == 0) {
     +        return;
     +   }
     CFRuntimeClass *cfClass = __CFRuntimeClassTable[typeID];
     void (*func)(CFTypeRef) = __CFRuntimeClassTable[typeID]->finalize;
     if (NULL != func) {
         func(cf);
     }
 }

CFTypeID with a value of 0 could really refer to _kCFRuntimeNotATypeID since the mask used in __CFTypeIDFromInfo seems to be the right one for 32bits. So, checking for _CFIsSwift(typeID, cf) would yield the same result. But unless something major changed irt object lifetime I doubt this could be considered a fix for the issue above.

uraimo commented 6 years ago

Fixed properly!