RFR: 8287609: macOS: SIGSEGV at [CoreFoundation] CFArrayGetCount / sun.font.CFont.getTableBytesNative

Nikita Gubarkov duke at openjdk.java.net
Wed Jun 1 18:09:26 UTC 2022


On Tue, 31 May 2022 23:39:09 GMT, Nikita Gubarkov <duke at openjdk.java.net> wrote:

> `CTFontCopyAvailableTables` can return null, which causes subsequent call to `CFArrayGetCount` to crash with SEGFAULT, just added a null-check.

<img width="1391" alt="Screen Shot 2022-06-01 at 8 20 04 PM" src="https://user-images.githubusercontent.com/9004656/171468848-58612bb1-6432-4c76-a13c-054e7f97f6d6.png">
It looks for a "maxp" table which is absent for this font. If you look down the stack, it's trying to find units per em and if we return NULL, then it just falls back to upem=1000 (libharfbuzz/hb-ot-head-table.hh:53):


/* If no valid head table found, assume 1000, which matches typical Type1 usage. */
return 16 <= upem && upem <= 16384 ? upem : 1000;


And as I can see, nobody expects `getTableBytesNative` to always return a table, it's perfectly fine to return NULL when it's not found. The only question is why `CTFontCopyAvailableTables` returns NULL - font handle looks OK as you can see on the screenshot.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8962



More information about the client-libs-dev mailing list