• Keith Randall's avatar
    cmd/cgo: rewrite CFTypeRef and subytes on Darwin to uintptr · d162a297
    Keith Randall authored
    Cgo currently maps CFTypeRef and its subtypes to unsafe.Pointer
    or a pointer to a named empty struct.
    
    However, Darwin sometimes encodes some of CFTypeRef's subtypes as a
    few int fields packed in a pointer wrapper. This hackery confuses the
    Go runtime as the pointers can look like they point to things that
    shouldn't be pointed at.
    
    Switch CFTypeRef and its subtypes to map to uintptr.
    
    Detecting the affected set of types is tricky, there are over 200 of
    them, and the set isn't static across Darwin versions. Fortunately,
    downcasting from CFTypeRef to a subtype requires calling CFGetTypeID,
    getting a CFTypeID token, and comparing that with a known id from a
    *GetTypeID() call. So we can find all the type names by detecting all
    the *GetTypeID() prototypes and rewriting the corresponding *Ref types
    to uintptr. This strategy covers all the cases I've checked and is
    unlikely to have a false positive.
    
    Update #23091.
    
    Change-Id: I487eb4105c9b4785ba564de9c38d472c8c9a76ac
    Reviewed-on: https://go-review.googlesource.com/87615
    Run-TryBot: Keith Randall <khr@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    d162a297
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...