I have a problem where passing certain CFAttributedStrings to CTLineCreateWithAttributedString triggers a segmentation fault. Here is a test case: ------------ #include #include static char string[] = { 230, 151, 165, 230, 156, 172, 232, 170, 158, 0 }; void test_me(int passADictionary) { CFStringRef str = CFStringCreateWithCString(NULL,string,kCFStringEncodingUTF8); if(!str) { printf("str == NULL\n"); exit(1); } CFDictionaryRef dict = CFDictionaryCreate(NULL,NULL,NULL,0,NULL,NULL); if(!dict) { printf("dict == NULL\n"); exit(1); } CFAttributedStringRef astr = CFAttributedStringCreate(NULL,str,(passADictionary == 1 ? dict : NULL)); if(!astr) { printf("astr == NULL\n"); exit(1); } CTLineRef line = CTLineCreateWithAttributedString(astr); if(!line) { printf("line == NULL\n"); exit(1); } } int main() { printf("Calling test_me(0)...\n"); test_me(0); printf("OK!\n"); printf("Calling test_me(1)...\n"); test_me(1); printf("OK!\n"); } ----------- If test_me is called with passADictionary=0, then the dictionary passed to CFAttributedStringCreate() is NULL, and everything works. However, if test_me is called with passADictionary=1, I pass in an empty immutable dictionary created with CFDictionaryCreate, and CTLineCreateWithAttributedString segfaults. Furthermore, notice how the string is the UTF8 encoded Japanese text "日本語". if I change the string at the top of the file to only contain ASCII characters, then both test_me(0) and test_me(1) succeed. So, can someone tell me what I'm doing wrong? I'd like to be able to pass non-NULL dictionaries to CFAttributedStringCreate(), since in particular I'm interested in setting kCTFontAttributeName to a CTFont.