From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#30320: 26.0.91; Crash when using lsp-ui-doc-mode Date: Sat, 10 Feb 2018 12:14:36 +0200 Message-ID: <83mv0h2ltf.fsf@gnu.org> References: <83po5oeil8.fsf@gnu.org> <83a7wrer8i.fsf@gnu.org> <5A757B30.9070402@gmx.at> <83y3ka9gmg.fsf@gnu.org> <83mv0pal74.fsf@gnu.org> <83y3k88ux5.fsf@gnu.org> <834lmv8j3u.fsf@gnu.org> <5A797560.9000602@gmx.at> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1518257654 3564 195.159.176.226 (10 Feb 2018 10:14:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Feb 2018 10:14:14 +0000 (UTC) Cc: 30320@debbugs.gnu.org, jake.goulding@gmail.com To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 10 11:14:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ekSAZ-0000Y1-UV for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Feb 2018 11:14:08 +0100 Original-Received: from localhost ([::1]:49745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekSCb-0002ax-9G for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Feb 2018 05:16:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekSCU-0002aF-Iy for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 05:16:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekSCQ-00073h-EY for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 05:16:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekSCQ-00073V-AH for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 05:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ekSCP-0002QW-WF for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 05:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2018 10:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30320-submit@debbugs.gnu.org id=B30320.15182577079221 (code B ref 30320); Sat, 10 Feb 2018 10:16:01 +0000 Original-Received: (at 30320) by debbugs.gnu.org; 10 Feb 2018 10:15:07 +0000 Original-Received: from localhost ([127.0.0.1]:36066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekSBX-0002Of-H9 for submit@debbugs.gnu.org; Sat, 10 Feb 2018 05:15:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekSBT-0002Nn-Tw for 30320@debbugs.gnu.org; Sat, 10 Feb 2018 05:15:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekSBK-00067L-FT for 30320@debbugs.gnu.org; Sat, 10 Feb 2018 05:14:58 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekSBK-00067B-B9; Sat, 10 Feb 2018 05:14:54 -0500 Original-Received: from [176.228.60.248] (port=3428 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ekSBJ-0005QA-MM; Sat, 10 Feb 2018 05:14:54 -0500 In-reply-to: <5A797560.9000602@gmx.at> (message from martin rudalics on Tue, 06 Feb 2018 10:29:04 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143080 Archived-At: > Date: Tue, 06 Feb 2018 10:29:04 +0100 > From: martin rudalics > CC: 30320@debbugs.gnu.org > > > As for preventing such crashes even though some Lisp does nonsensical > > things: I think a TTY frame cannot be less than 3 or 4 lines plus the > > number of lines used for the menu bar. Martin, WDYT about adding > > these limitations to adjust_frame_size? > > A better location is when adjusting min_size in frame_windows_min_size > here: > > int min_size = XINT (par_size); > > /* Don't allow phantom frames. */ > if (min_size < 1) > min_size = 1; > > As you see we currently allow 1 here for width and height measured in > characters. Feel free to change this any way you want - > FRAME_TERMCAP_P conditioned it shouldn't hurt and be suitable for the > release version. If you want me to do it, please tell me the value(s) > you consider appropriate and where to apply it. > > I never cared about this because I never was able to crash Emacs when > using small sizes. Does the below look reasonable and safe for emacs-26? Jake, can you see if this patch avoids the crash even with the original problem in lsp-ui-doc-mode? diff --git a/src/frame.c b/src/frame.c index d5b080d..b2bc031 100644 --- a/src/frame.c +++ b/src/frame.c @@ -349,6 +349,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, { struct frame *f = XFRAME (frame); Lisp_Object par_size; + int retval; if ((!NILP (horizontal) && NUMBERP (par_size = get_frame_param (f, Qmin_width))) @@ -361,15 +362,27 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, if (min_size < 1) min_size = 1; - return (NILP (pixelwise) - ? min_size - : min_size * (NILP (horizontal) - ? FRAME_LINE_HEIGHT (f) - : FRAME_COLUMN_WIDTH (f))); + retval = (NILP (pixelwise) + ? min_size + : min_size * (NILP (horizontal) + ? FRAME_LINE_HEIGHT (f) + : FRAME_COLUMN_WIDTH (f))); } else - return XINT (call4 (Qframe_windows_min_size, frame, horizontal, - ignore, pixelwise)); + retval = XINT (call4 (Qframe_windows_min_size, frame, horizontal, + ignore, pixelwise)); + /* Don't allow too snall height of text-mode frames, or else cm.c + might abort in cmcheckmagic. */ + if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) && NILP (horizontal)) + { + int min_height = (FRAME_MENU_BAR_LINES (f) + + FRAME_WANTS_MODELINE_P (f) + + 2); /* one text line and one echo-area line */ + if (retval < min_height) + retval = min_height; + } + + return retval; }