Skip to content

systemfonts::system_fonts crashes (segfault) when used in future #41

Description

@stefanoborini

This code produces a hard segfault:

future::plan(future::multiprocess)

fut <- future::future({
  systemfonts::system_fonts()
})

r <- future::value(fut)
print(r)
[1] "Using environment default"

 *** caught segfault ***
address 0x110, cause 'memory not mapped'

Traceback:
 1: systemfonts::system_fonts()
 2: eval(quote({    systemfonts::system_fonts()}), new.env())
 3: eval(quote({    systemfonts::system_fonts()}), new.env())
 4: eval(expr, p)
 5: eval(expr, p)
 6: eval.parent(substitute(eval(quote(expr), envir)))
 7: local({    systemfonts::system_fonts()})
 8: doTryCatch(return(expr), name, parentenv, handler)
 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
11: tryCatch({    ...future.value <- local({        systemfonts::system_fonts()    })    future::FutureResult(value = ...future.value, version = "1.8")}, error = function(cond) {    calls <- sys.calls()    structure(list(value = NULL, value2 = NA, condition = cond,         calls = calls, version = "1.8"), class = "FutureResult")}, finally = {    {        {            {                options(mc.cores = ...future.mc.cores.old)            }            future::plan(list(function (expr, envir = parent.frame(),                 substitute = TRUE, lazy = FALSE, seed = NULL,                 globals = TRUE, workers = availableCores(), gc = FALSE,                 earlySignal = FALSE, label = NULL, ...)             {                if (substitute)                   expr <- substitute(expr)                fun <- if (supportsMulticore())                   multicore                else multisession                fun(expr = expr, envir = envir, substitute = FALSE,                   lazy = lazy, seed = seed, globals = globals,                   workers = workers, gc = gc, earlySignal = earlySignal,                   label = label, ...)            }), .cleanup = FALSE, .init = FALSE)        }        options(...future.oldOptions)    }})
12: eval(expr, env)

R 3.6.0, systemfonts 0.2.3 on macos.

lldb backtrace

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x110)
  * frame #0: 0x00007fff6f5a2e47 libdispatch.dylib`_dispatch_mgr_queue_push + 41
    frame #1: 0x00007fff6f59ebab libdispatch.dylib`_dispatch_lane_resume_activate + 58
    frame #2: 0x00007fff44919d9a CarbonCore`connectToCoreServicesD() + 245
    frame #3: 0x00007fff44919c74 CarbonCore`getStatus() + 24
    frame #4: 0x00007fff44919bef CarbonCore`scCreateSystemServiceVersion + 49
    frame #5: 0x00007fff44919964 CarbonCore`FileIDTreeGetCachedPort + 213
    frame #6: 0x00007fff449197d0 CarbonCore`FSNodeStorageGetAndLockCurrentUniverse + 83
    frame #7: 0x00007fff4491965a CarbonCore`FileIDTreeGetAndLockVolumeEntryForDeviceID + 38
    frame #8: 0x00007fff449195b7 CarbonCore`FSMount::FSMount(unsigned int, FSMountNumberType, int*, unsigned int const*) + 75
    frame #9: 0x00007fff44919531 CarbonCore`FSMountPrepare + 69
    frame #10: 0x00007fff5784aa30 CoreServicesInternal`MountInfoPrepare(void***, unsigned int, int, void*, unsigned int const*, __CFURL const*, __CFError**) + 43
    frame #11: 0x00007fff5784a428 CoreServicesInternal`parseAttributeBuffer(__CFAllocator const*, unsigned char const*, unsigned char, attrlist const*, void const*, void**, _FileAttributes*, unsigned int*) + 3209
    frame #12: 0x00007fff57849491 CoreServicesInternal`corePropertyProviderPrepareValues(__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 834
    frame #13: 0x00007fff578490ee CoreServicesInternal`prepareValuesForBitmap(__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 360
    frame #14: 0x00007fff5784ca0f CoreServicesInternal`_FSURLCopyResourcePropertyValuesAndFlags + 581
    frame #15: 0x00007fff4368f24b CoreFoundation`_CFURLCopyResourcePropertyValuesAndFlags + 127
    frame #16: 0x00007fff41bb6236 libFontParser.dylib`FPPathGetCatalogValues(char const*, FInfo*, unsigned long long*, unsigned long long*) + 187
    frame #17: 0x00007fff41bb3ec5 libFontParser.dylib`TFont::CreateFontEntities(char const*, bool, bool&, short, char const*, bool) + 85
    frame #18: 0x00007fff41bb664a libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, bool, short, char const*) + 264
    frame #19: 0x00007fff41b6649e libFontParser.dylib`FPFontCreateFontsWithPath + 158
    frame #20: 0x00007fff43a983b7 CoreGraphics`create_private_data_array_with_path + 29
    frame #21: 0x00007fff43a980bf CoreGraphics`CGFontCreateFontsWithPath + 26
    frame #22: 0x00007fff43a97ce9 CoreGraphics`CGFontCreateFontsWithURL + 345
    frame #23: 0x00007fff4528642b CoreText`CreateFontsWithURL(__CFURL const*, bool) + 199
    frame #24: 0x00007fff45368a4c CoreText`CTFontManagerCreateFontDescriptorsFromURL + 37
    frame #25: 0x0000000107ab625a systemfonts.so`addFontIndex(FontDescriptor*) + 378
    frame #26: 0x0000000107ab6c80 systemfonts.so`createFontDescriptor(__CTFontDescriptor const*) + 992
    frame #27: 0x0000000107ab72a8 systemfonts.so`getAvailableFonts() + 520
    frame #28: 0x0000000107aa6103 systemfonts.so`system_fonts() + 467

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions