From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: NS port crashes when interacting with the profiler on the menu bar Date: Wed, 13 Jun 2018 20:57:49 +0100 Message-ID: <20180613195749.GA31667@breton.holly.idiocy.org> References: <20180612193933.GA889@breton.holly.idiocy.org> <124c265f-9c41-6041-8a7f-ba2e3fcabd07@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1528919788 30319 195.159.176.226 (13 Jun 2018 19:56:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2018 19:56:28 +0000 (UTC) User-Agent: Mutt/1.10.0 (2018-05-17) Cc: emacs-devel@gnu.org To: Jimmy Yuen Ho Wong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 13 21:56:24 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fTBsV-0007mV-TK for ged-emacs-devel@m.gmane.org; Wed, 13 Jun 2018 21:56:24 +0200 Original-Received: from localhost ([::1]:36647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTBud-0000Br-6N for ged-emacs-devel@m.gmane.org; Wed, 13 Jun 2018 15:58:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTBu0-0000Bj-4N for emacs-devel@gnu.org; Wed, 13 Jun 2018 15:57:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTBty-0002tY-ED for emacs-devel@gnu.org; Wed, 13 Jun 2018 15:57:56 -0400 Original-Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:38140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTBtx-0002sK-W5 for emacs-devel@gnu.org; Wed, 13 Jun 2018 15:57:54 -0400 Original-Received: by mail-wm0-x22c.google.com with SMTP id 69-v6so7648776wmf.3 for ; Wed, 13 Jun 2018 12:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=4PBMF/TVjyLS3PE8wWZAL/UUatsYkwn7wQ/3jWjeHDY=; b=UpEwkFFaw+0mJnvjPzGWgKZlBUzTLdtJyQ+BwKHIVw1q7VA5S9IzimTQvbwAlZYhVu PyscfRZJQxKPGywaonkoz2PYNOqklfnAXh2zRyxcl/uLd4kZLTeb4eUNk/dPRlp7qScd xBZcdGCxmCkScvkANaNQZALX2VBcpeulFtP3KjjPHQqRh4G1kMDkCGnGDYvRxm4mKjyn /J1Guel3rcHiWGtvsuQHsNQyylZu8moUuPD1y8zZjmBM9+LV3+gCBiwCPvIXDS7ln3IO 52TLbUQYMAqKLZXoT4PCTD2m6k87TksAgULj/11PODxeTU8DDoXqeRyNokSW9ADn453+ 0zkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=4PBMF/TVjyLS3PE8wWZAL/UUatsYkwn7wQ/3jWjeHDY=; b=bBp3b319a0iyFs8GxKH5ikbivytezq4UNCozZ0d1qsUEG0xoas+/SPU2s8GyBlHJH4 gGCYVQ2YslwL2A0irecuXJ2m7mJWQrW3pBngXBz5E7aVDBu4oowgSd+Q6rDsVrfixtvj 4/qOwfMuOE6bewz4ofnpMKkPf+ErxRvJXUVCv70qTecJ01gpbwxe2zIBEJNdGsp+qb0S i8SOExU67Cl9B5q4vhEpH8V3mKNesBst+jwmM9T4rpFKGc5Dqvi0CMrCchZLflTsSQJF VGojk/mB7zXm02qlJ+Nw10j7fYwEh60vLVNMiZizBss7ZcYLo76jIlI5lIuJqrWYddG2 jDkA== X-Gm-Message-State: APt69E0QcKCTQm5QUlA1KHtKSJd4RNaWcGc6GJNYI1mkDaqL1wruGBBt LnrPWf/vh5xKJHX0aMFSUJQ= X-Google-Smtp-Source: ADUXVKIUEOoqJJBHkBHNOst+n70y7eZetISNzvIUxjjjVF8qr3wwGY2A0oHQhq6D7jQ3XTjmvvxVww== X-Received: by 2002:a1c:5582:: with SMTP id j124-v6mr4574670wmb.153.1528919872430; Wed, 13 Jun 2018 12:57:52 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-2050-339f-0e48-d89b.holly.idiocy.org. [2001:8b0:3f8:8129:2050:339f:e48:d89b]) by smtp.gmail.com with ESMTPSA id v12-v6sm2370241wmc.35.2018.06.13.12.57.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 12:57:51 -0700 (PDT) Content-Disposition: inline In-Reply-To: <124c265f-9c41-6041-8a7f-ba2e3fcabd07@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226309 Archived-At: --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Jun 12, 2018 at 09:02:35PM +0100, Jimmy Yuen Ho Wong wrote: > >> Case 2 repro: > >> > >> Put this into your init file: > >> > >> (set-fontset-font "fontset-default" 'unicode "Apple Color Emoji" nil > >> 'append) > >> > >> Crashes on start up. > > Again I can’t reproduce it. Do you have anything else in your init.el > > that might try to display an emoji or similar? In fact, you’ve got the > > colour emoji patch applied, right? I wonder if that changes > > something... > Yes I have MacPort's multifonts_color patch applied. It doesn’t make any difference here. It’s odd. Can you reproduce the crash using -Q? Do you have symbola installed? > >> Case 3 repro: > >> > >> 1. Goto System Preferences > Keyword and turn on Show keyboard and emoji > >> viewers in menu bar. > >> 2. Go to emacs NS port, turn on Show Emoji & Symbols to get the emoji > >> viewer out, insert some Emoji > >> 3. Internal Error dialog pops up, Emacs caught the crash this time. > > This isn’t a crash, right? I’m pretty sure this is fixed in master, > > specifically commit 703ac3ea1c1ce381f385469a0e88bc29d3fe83c2. I think > > this should be easily back ported to Emacs 26 if it’s causing crashes. > This is a crash, but not a fatal crash, it's the Emacs NS port or Cocoa > caught it and popped up an Internal Error dialog. For the dialog I can > choose to let it crash the entire process or continue and ignore it. Two patches attached which I believe fix this in emacs-26. I think they’re safe. The second patch is part of commit 1daac66a6eedbcbfa32ab920b5c579872d989517 on master, but it adds a new feature, so probably shouldn’t be applied in full. -- Alan Third --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-inserting-non-BMP-characters.patch" >From 023fc1a8b3902caf7221805db8ac262fbcbe3ba0 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Mon, 25 Dec 2017 22:00:00 +0100 Subject: [PATCH] Allow inserting non-BMP characters * src/coding.h (UTF_16_HIGH_SURROGATE_P, UTF_16_LOW_SURROGATE_P): Move from coding.c and document. (surrogates_to_codepoint): New function. * src/nsterm.m (insertText:): Properly handle surrogate pairs. (cherry picked from commit 703ac3ea1c1ce381f385469a0e88bc29d3fe83c2) --- src/coding.c | 7 ------- src/coding.h | 24 ++++++++++++++++++++++++ src/nsterm.m | 25 +++++++++++++++++++------ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/coding.c b/src/coding.c index e756ba169d..121614fad1 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1515,13 +1515,6 @@ encode_coding_utf_8 (struct coding_system *coding) /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". Return true if a text is encoded in one of UTF-16 based coding systems. */ -#define UTF_16_HIGH_SURROGATE_P(val) \ - (((val) & 0xFC00) == 0xD800) - -#define UTF_16_LOW_SURROGATE_P(val) \ - (((val) & 0xFC00) == 0xDC00) - - static bool detect_coding_utf_16 (struct coding_system *coding, struct coding_detection_info *detect_info) diff --git a/src/coding.h b/src/coding.h index 2a87fc32e9..502c472314 100644 --- a/src/coding.h +++ b/src/coding.h @@ -662,6 +662,30 @@ struct coding_system /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op. */ #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, true) +/* Return true if VAL is a high surrogate. VAL must be a 16-bit code + unit. */ + +#define UTF_16_HIGH_SURROGATE_P(val) \ + (((val) & 0xFC00) == 0xD800) + +/* Return true if VAL is a low surrogate. VAL must be a 16-bit code + unit. */ + +#define UTF_16_LOW_SURROGATE_P(val) \ + (((val) & 0xFC00) == 0xDC00) + +/* Return the Unicode code point for the given UTF-16 surrogates. */ + +INLINE int +surrogates_to_codepoint (int low, int high) +{ + eassert (0 <= low && low <= 0xFFFF); + eassert (0 <= high && high <= 0xFFFF); + eassert (UTF_16_LOW_SURROGATE_P (low)); + eassert (UTF_16_HIGH_SURROGATE_P (high)); + return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); +} + /* Extern declarations. */ extern Lisp_Object code_conversion_save (bool, bool); extern bool encode_coding_utf_8 (struct coding_system *); diff --git a/src/nsterm.m b/src/nsterm.m index e4a9b014f4..d51782e538 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6317,14 +6317,13 @@ flag set (this is probably a bug in the OS). by doCommandBySelector: deleteBackward: */ - (void)insertText: (id)aString { - int code; - int len = [(NSString *)aString length]; - int i; + NSString *s = aString; + NSUInteger len = [s length]; NSTRACE ("[EmacsView insertText:]"); if (NS_KEYLOG) - NSLog (@"insertText '%@'\tlen = %d", aString, len); + NSLog (@"insertText '%@'\tlen = %lu", aString, (unsigned long) len); processingCompose = NO; if (!emacs_event) @@ -6334,10 +6333,24 @@ - (void)insertText: (id)aString if (workingText != nil) [self deleteWorkingText]; + /* It might be preferable to use getCharacters:range: below, + cf. https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaPerformance/Articles/StringDrawing.html#//apple_ref/doc/uid/TP40001445-112378. + However, we probably can't use SAFE_NALLOCA here because it might + exit nonlocally. */ + /* now insert the string as keystrokes */ - for (i =0; iFrom f3e78727d77c50594fc9f4b03b8640825af49016 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 24 Dec 2017 15:40:03 +0000 Subject: [PATCH] Handle NSAttributedString inputs (bug#29837) ; Do not merge to master. * src/nsterm.m (EmacsView::insertText): Handle NSAttributedString. --- src/nsterm.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index d51782e538..c8b4a87990 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6317,11 +6317,18 @@ flag set (this is probably a bug in the OS). by doCommandBySelector: deleteBackward: */ - (void)insertText: (id)aString { - NSString *s = aString; - NSUInteger len = [s length]; + NSString *s; + NSUInteger len; NSTRACE ("[EmacsView insertText:]"); + if ([aString isKindOfClass:[NSAttributedString class]]) + s = [aString string]; + else + s = aString; + + len = [s length]; + if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %lu", aString, (unsigned long) len); processingCompose = NO; -- 2.17.1 --dDRMvlgZJXvWKvBx--