unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
@ 2021-10-04 13:36 Indrajeet Khandekar
  2021-10-04 18:22 ` martin rudalics
  0 siblings, 1 reply; 14+ messages in thread
From: Indrajeet Khandekar @ 2021-10-04 13:36 UTC (permalink / raw)
  To: 51007

[-- Attachment #1: Type: text/plain, Size: 6267 bytes --]


1. start vanila, emacs session.
2. add following configuration.
(setq debug-on-quit 1)
(setq display-buffer-alist
       '(
         ("\\*\\(Async Shell Command\\|Shell Command Output\\)\\*"
         (display-buffer-reuse-window display-buffer-in-side-window)
         (window-width . 0.40)
         (side . right)
         (slot . 0))
         ("\\*Shell\\*"
         (display-buffer-reuse-window display-buffer-in-side-window)
         (window-width . 0.40)
         (side . top)
         (slot . 0))
        )
       )

3. split the window horizontally `C-x 3`
4. start a shell `M-x shell RET`
5. Run a async shell `M-x async-command-shell ls RET`
6. Run `M-x window-toggle-side-windows RET` the session stalls nothing works.

- C-g does not help in this case.
- C-x C-z does not help.
- C-x C-c does not help.


In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2021-03-28 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.6

Recent messages:


Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER GMP

Important settings:
  value of $LANG: en_IN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  global-company-mode: t
  company-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  shell-dirtrack-mode: t
  ivy-mode: t
  which-key-mode: t
  global-page-break-lines-mode: t
  page-break-lines-mode: t
  override-global-mode: t
  recentf-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:


Features:
(shadow sort mail-extr emacsbug sendmail markdown-mode tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat
org-colview org-archive swiper tabify org-capture org-duration sh-script
smie executable rx bookmark pp cal-move diary-lib diary-loaddefs cal-iso
org-element avl-tree ol-eww eww mm-url url-queue ol-rmail ol-mhe ol-irc
ol-info ol-gnus nnir gnus-sum shr svg dom gnus-group gnus-undo
gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
parse-time iso8601 gnus-spec gnus-int gnus-range message rfc822 mml
mml-sec epa derived epg epg-config mailabbrev gmm-utils mailheader
gnus-win gnus nnheader gnus-util rmail rmail-loaddefs
text-property-search ol-docview doc-view jka-compr image-mode exif dired
dired-loaddefs ol-bibtex bibtex ol-bbdb ol-w3m face-remap org-agenda
org-refile disp-table tsdh-light-theme company-oddmuse company-keywords
company-etags company-gtags company-dabbrev-code company-dabbrev
company-files company-capf company-cmake company-xcode company-clang
company-semantic company-eclim company-template company-bbdb company
pcase helpful imenu trace edebug backtrace info-look f dash-functional
help-fns radix-tree elisp-refs s loop evil evil-keybindings
evil-integration undo-tree diff evil-maps evil-commands reveal flyspell
ispell evil-jumps evil-command-window evil-types evil-search evil-ex
shell evil-macros evil-repeat evil-states evil-core evil-common windmove
rect evil-digraphs evil-vars go-mode find-file ffap thingatpt etags
fileloop generator xref project compile ivy delsel ivy-faces ivy-overlay
colir color restart-emacs which-key org-jira org-jira-sdk jiralib
request autorevert filenotify mail-utils soap-client mm-decode mm-bodies
mm-encode url-http url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr url-gw nsm rmc puny warnings rng-xsd rng-dt
rng-util xsd-regexp xml dash ls-lisp org-clock org ob ob-tangle ob-ref
ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete pcomplete comint ansi-color org-list org-faces
org-entities time-date noutline outline org-version ob-emacs-lisp
ob-core ob-eval org-table ol org-keys org-compat org-macs org-loaddefs
advice find-func cal-menu calendar cal-loaddefs diminish
page-break-lines hackernews url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
format-spec cus-edit cus-start cus-load use-package use-package-delight
use-package-diminish edmacro kmacro use-package-bind-key bind-key
easy-mmode recentf tree-widget wid-edit modus-themes hydra ring lv
cl-extra help-mode use-package-ensure use-package-core finder-inf info
package easymenu browse-url url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 491087 55526)
(symbols 48 39800 2)
(strings 32 142076 4678)
(string-bytes 1 4451885)
(vectors 16 60803)
(vector-slots 8 1081859 88134)
(floats 8 523 471)
(intervals 56 5270 1535)
(buffers 1000 29))

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3681 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-04 13:36 bug#51007: 27.2; emacs hangs when using window-toggle-side-windows Indrajeet Khandekar
@ 2021-10-04 18:22 ` martin rudalics
       [not found]   ` <01944062-1C37-4B9A-98B9-F79F29D3B8F4@taranawireless.com>
  2021-10-05 10:53   ` Indrajeet Khandekar
  0 siblings, 2 replies; 14+ messages in thread
From: martin rudalics @ 2021-10-04 18:22 UTC (permalink / raw)
  To: Indrajeet Khandekar, 51007

 > 1. start vanila, emacs session.
 > 2. add following configuration.
 > (setq debug-on-quit 1)
 > (setq display-buffer-alist
 >         '(
 >           ("\\*\\(Async Shell Command\\|Shell Command Output\\)\\*"
 >           (display-buffer-reuse-window display-buffer-in-side-window)
 >           (window-width . 0.40)
 >           (side . right)
 >           (slot . 0))
 >           ("\\*Shell\\*"
 >           (display-buffer-reuse-window display-buffer-in-side-window)
 >           (window-width . 0.40)
 >           (side . top)
 >           (slot . 0))
 >          )
 >         )
 >
 > 3. split the window horizontally `C-x 3`
 > 4. start a shell `M-x shell RET`
 > 5. Run a async shell `M-x async-command-shell ls RET`
 > 6. Run `M-x window-toggle-side-windows RET` the session stalls nothing works.
 >
 > - C-g does not help in this case.
 > - C-x C-z does not help.
 > - C-x C-c does not help.
 >
 >
 > In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 > of 2021-03-28 built on builder10-14.porkrind.org
 > Windowing system distributor 'Apple', version 10.3.2022
 > System Description:  macOS 11.6

I can't try your recipe because `async-command-shell' isn't defined
here.  When I try with

(setq debug-on-quit 1)
(setq display-buffer-alist
        '(
          ("\\*Info\\*"
          (display-buffer-reuse-window display-buffer-in-side-window)
          (window-width . 0.40)
          (side . right)
          (slot . 0))
          ("\\*Help\\*"
          (display-buffer-reuse-window display-buffer-in-side-window)
          (window-height . 0.40)
          (side . top)
          (slot . 0))
         )
        )

everything works as expected so the problem seems that shell command
output wants to use the window used for ls, or vice-versa.

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
       [not found]   ` <01944062-1C37-4B9A-98B9-F79F29D3B8F4@taranawireless.com>
@ 2021-10-05  8:09     ` martin rudalics
  0 siblings, 0 replies; 14+ messages in thread
From: martin rudalics @ 2021-10-05  8:09 UTC (permalink / raw)
  To: 51007

> Sorry, I made a mistake while sending the report, I used a wrong version of emacs,
>
> This is observed only on emacs 27.1

I don't have Emacs 27.1 installed here.  But I tried with Emacs 27.2
plus the patch for Bug#50867 applied and yet don't see any problems.

> And the `async-command-shell` is typo it should have been, `async-shell-command`

I noted that meanwhile and already use your recipe.  I still think that
when you do that something goes awry that is not related to toggling but
maybe to shell output.  Could you try with the *Help*/*Info* example I
posted earlier to exclude that possibility?

But maybe also 'window--sides-reverse-frame' is the culprit.  So could
you try with the call of 'window--sides-reverse-frame' removed from
'window-toggle-side-windows'?  I didn't give that much testing then.

Thanks, martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-04 18:22 ` martin rudalics
       [not found]   ` <01944062-1C37-4B9A-98B9-F79F29D3B8F4@taranawireless.com>
@ 2021-10-05 10:53   ` Indrajeet Khandekar
  2021-10-05 12:37     ` martin rudalics
  1 sibling, 1 reply; 14+ messages in thread
From: Indrajeet Khandekar @ 2021-10-05 10:53 UTC (permalink / raw)
  To: martin rudalics; +Cc: 51007


[-- Attachment #1.1: Type: text/plain, Size: 4684 bytes --]

Hi, I tried with following code, in scratch 

(defun window-toggle-side-windows (&optional frame)
  "Toggle display of side windows on specified FRAME.
FRAME must be a live frame and defaults to the selected one.

If FRAME has at least one side window, delete all side
windows on FRAME after saving FRAME's state in the
FRAME's `window-state' frame parameter.  Otherwise,
restore any side windows recorded in FRAME's `window-state'
parameter, leaving FRAME's main window alone.  Signal an
error if FRAME has no side windows and no saved state for
it is found."
  (interactive)
  (let* ((frame (window-normalize-frame frame))
         (window--sides-inhibit-check t)
         state)
    (cond
     ((window-with-parameter 'window-side nil frame)
      ;; At least one side window exists.  Remove all side windows after
      ;; saving FRAME's state in its `window-state' parameter.
      (set-frame-parameter
       frame 'window-state (window-state-get (frame-root-window frame)))
      (let ((ignore-window-parameters t))
        (delete-other-windows (window-main-window frame))))
     ((setq state (frame-parameter frame 'window-state))
      ;; A window state was saved for FRAME.  Restore it and put the
      ;; current root window into its main window.
      (let ((window-combination-resize t)
            (main-state (window-state-get (frame-root-window frame))))
        (window-state-put state (frame-root-window frame) t)
        (window-state-put main-state (window-main-window frame)))
      (window--sides-reverse-frame frame))
     (t
      (error "No side windows state found")))))
(setq display-buffer-alist
      '(
        ("\\*Info\\*"
        (display-buffer-reuse-window display-buffer-in-side-window)
        (window-width . 0.40)
        (side . right)
        (slot . 0))
        ("\\*Help\\*"
        (display-buffer-reuse-window display-buffer-in-side-window)
        (window-height . 0.40)
        (side . top)
        (slot . 0))
       )
      )


And also without `window—-sides-reverse-frame`

(defun window-toggle-side-windows (&optional frame)
  "Toggle display of side windows on specified FRAME.
FRAME must be a live frame and defaults to the selected one.

If FRAME has at least one side window, delete all side
windows on FRAME after saving FRAME's state in the
FRAME's `window-state' frame parameter.  Otherwise,
restore any side windows recorded in FRAME's `window-state'
parameter, leaving FRAME's main window alone.  Signal an
error if FRAME has no side windows and no saved state for
it is found."
  (interactive)
  (let* ((frame (window-normalize-frame frame))
         (window--sides-inhibit-check t)
         state)
    (cond
     ((window-with-parameter 'window-side nil frame)
      ;; At least one side window exists.  Remove all side windows after
      ;; saving FRAME's state in its `window-state' parameter.
      (set-frame-parameter
       frame 'window-state (window-state-get (frame-root-window frame)))
      (let ((ignore-window-parameters t))
        (delete-other-windows (window-main-window frame))))
     ((setq state (frame-parameter frame 'window-state))
      ;; A window state was saved for FRAME.  Restore it and put the
      ;; current root window into its main window.
      (let ((window-combination-resize t)
            (main-state (window-state-get (frame-root-window frame))))
        (window-state-put state (frame-root-window frame) t)
        (window-state-put main-state (window-main-window frame)))
      )
     (t
      (error "No side windows state found")))))
(setq display-buffer-alist
      '(
        ("\\*Info\\*"
        (display-buffer-reuse-window display-buffer-in-side-window)
        (window-width . 0.40)
        (side . right)
        (slot . 0))
        ("\\*Help\\*"
        (display-buffer-reuse-window display-buffer-in-side-window)
        (window-height . 0.40)
        (side . top)
        (slot . 0))
       )
      )

In both cases, after doing following:

1. `C-x 3`
2. `C-h i`
3. `C-h m`
4. `M-x window-toggle-side-windows RET`

emacs still hangs.

Indrajeet.


> On 04-Oct-2021, at 11:52 PM, martin rudalics <rudalics@gmx.at> wrote:
> 
> (setq display-buffer-alist
>       '(
>         ("\\*Info\\*"
>         (display-buffer-reuse-window display-buffer-in-side-window)
>         (window-width . 0.40)
>         (side . right)
>         (slot . 0))
>         ("\\*Help\\*"
>         (display-buffer-reuse-window display-buffer-in-side-window)
>         (window-height . 0.40)
>         (side . top)
>         (slot . 0))
>        )
>       )


[-- Attachment #1.2: Type: text/html, Size: 20397 bytes --]

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3681 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-05 10:53   ` Indrajeet Khandekar
@ 2021-10-05 12:37     ` martin rudalics
       [not found]       ` <6D2FC628-BF92-4C35-8552-FBBEF0C7FDDC@taranawireless.com>
  0 siblings, 1 reply; 14+ messages in thread
From: martin rudalics @ 2021-10-05 12:37 UTC (permalink / raw)
  To: Indrajeet Khandekar; +Cc: 51007

 > Hi, I tried with following code, in scratch
[...]
 > In both cases, after doing following:
 >
 > 1. `C-x 3`
 > 2. `C-h i`
 > 3. `C-h m`
 > 4. `M-x window-toggle-side-windows RET`
 >
 > emacs still hangs.

Both work here in Emacs 26 and 27 - with 'window-toggle-side-windows'
called twice.  Does yours really hang already in the first call?

Anyway, please with emacs -Q do C-x 5 2, C-u C-M-x in your version of
`window-toggle-side-windows' in *scratch* on the second frame and in the
first frame display *Messages* and then proceed as above, stepping
through that function with SPC.  This way we should be able to find out
where it hangs.  If you find the culprit, please edebug the function
where it hangs - originally I'd have suspected 'window-state-put' but if
it really hangs in the first call it would be 'window-state-get'.

Thanks, martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
       [not found]       ` <6D2FC628-BF92-4C35-8552-FBBEF0C7FDDC@taranawireless.com>
@ 2021-10-09 18:57         ` martin rudalics
  2021-10-10  6:20           ` Eli Zaretskii
  2021-10-10 17:16         ` martin rudalics
  1 sibling, 1 reply; 14+ messages in thread
From: martin rudalics @ 2021-10-09 18:57 UTC (permalink / raw)
  To: Indrajeet Khandekar; +Cc: 51007

 > I made little progress with this, and here are few of my observations.
 > 1. The bug is producible in non-gui, when starting emacs with `-nw`, even on emacs27.2
 >     I am using the info and help buffers as side windows.

Very good.  Can you reproduce it with a GUI build too?  I still cannot
here.

 > 2. I tried the stepping through process, it took me through following function calls
 >     `window-toggle-side-windows`
 >     `delete-other-windows`
 >      in this function it takes me to
 >     `delete-other-windows-internal`
 >
 >        ;; If WINDOW is the main window of its frame do nothing.
 >        (if (eq window main)
 >            ;; Give a message to the user if this has been called as a
 >            ;; command.
 >            (when (called-interactively-p 'interactive)
 >              (message "No other windows to delete"))
 > =>      (delete-other-windows-internal window main)
 >          (window--check frame))
 >
 > And it stalls after this point, the `window` and `main` argument have non-nil values.

Here on the emacs-28 branch (with a non-optimized GTK build) I get an
assertion failure instead with the following backtrace:

#0  0x00000000005acb54 in terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at ../../src/emacs.c:400
#1  0x000000000065acc7 in die (msg=0x786590 "r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA] && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]", file=0x78629b "../../src/dispnew.c", line=1899) at ../../src/alloc.c:7478
#2  0x000000000041cfab in fake_current_matrices (window=XIL(0x2444a2d)) at ../../src/dispnew.c:1898
#3  0x000000000041ce37 in fake_current_matrices (window=XIL(0x252e995)) at ../../src/dispnew.c:1882
#4  0x000000000041d7ba in adjust_frame_glyphs_for_frame_redisplay (f=0x24447e8) at ../../src/dispnew.c:2111
#5  0x000000000041cd11 in adjust_frame_glyphs (f=0x24447e8) at ../../src/dispnew.c:1838
#6  0x00000000004d409c in Fdelete_other_windows_internal (window=XIL(0x252e995), root=XIL(0x242e1b5)) at ../../src/window.c:3427
#7  0x000000000069488b in funcall_subr (subr=0xc589a0 <Sdelete_other_windows_internal>, numargs=2, args=0x7ffcbd5c2870) at ../../src/eval.c:3103
#8  0x0000000000694324 in Ffuncall (nargs=3, args=0x7ffcbd5c2868) at ../../src/eval.c:3026
#9  0x00000000006eed2a in exec_byte_code (bytestr=XIL(0x7f23c134b2d4), vector=XIL(0x7f23c134b045), maxdepth=make_fixnum(11), args_template=make_fixnum(512), nargs=1, args=0x7ffcbd5c2de8) at ../../src/bytecode.c:632
#10 0x0000000000694aec in fetch_and_exec_byte_code (fun=XIL(0x7f23c134afed), syms_left=make_fixnum(512), nargs=1, args=0x7ffcbd5c2de0) at ../../src/eval.c:3150
#11 0x0000000000694f72 in funcall_lambda (fun=XIL(0x7f23c134afed), nargs=1, arg_vector=0x7ffcbd5c2de0) at ../../src/eval.c:3231
#12 0x0000000000694c96 in apply_lambda (fun=XIL(0x7f23c134afed), args=XIL(0x254a5b3), count=18) at ../../src/eval.c:3175
#13 0x0000000000692dbd in eval_sub (form=XIL(0x254a583)) at ../../src/eval.c:2548
#14 0x000000000068ca77 in Fprogn (body=XIL(0)) at ../../src/eval.c:468
#15 0x000000000068ebce in Flet (args=XIL(0x254a573)) at ../../src/eval.c:1054
#16 0x00000000006927c2 in eval_sub (form=XIL(0x254a533)) at ../../src/eval.c:2454
#17 0x000000000068ca77 in Fprogn (body=XIL(0)) at ../../src/eval.c:468
#18 0x000000000068c964 in Fcond (args=XIL(0x254a5e3)) at ../../src/eval.c:448
#19 0x00000000006927c2 in eval_sub (form=XIL(0x254a403)) at ../../src/eval.c:2454
#20 0x000000000068ca77 in Fprogn (body=XIL(0)) at ../../src/eval.c:468
#21 0x000000000068e6bb in FletX (args=XIL(0x254abd3)) at ../../src/eval.c:986
#22 0x00000000006927c2 in eval_sub (form=XIL(0x254ab33)) at ../../src/eval.c:2454
#23 0x000000000068ca77 in Fprogn (body=XIL(0)) at ../../src/eval.c:468
#24 0x000000000069547b in funcall_lambda (fun=XIL(0x254a1a3), nargs=0, arg_vector=0x0) at ../../src/eval.c:3306
#25 0x000000000069448b in Ffuncall (nargs=1, args=0x7ffcbd5c3878) at ../../src/eval.c:3042
#26 0x0000000000688029 in Ffuncall_interactively (nargs=1, args=0x7ffcbd5c3878) at ../../src/callint.c:260
#27 0x000000000069475e in funcall_subr (subr=0xc63f20 <Sfuncall_interactively>, numargs=1, args=0x7ffcbd5c3878) at ../../src/eval.c:3081
#28 0x0000000000694324 in Ffuncall (nargs=2, args=0x7ffcbd5c3870) at ../../src/eval.c:3026
#29 0x0000000000693112 in Fapply (nargs=3, args=0x7ffcbd5c3870) at ../../src/eval.c:2609
#30 0x00000000006884b1 in Fcall_interactively (function=XIL(0x7f23c09fcab8), record_flag=XIL(0), keys=XIL(0x7f23c18b69f5)) at ../../src/callint.c:353
#31 0x00000000006948b7 in funcall_subr (subr=0xc63f60 <Scall_interactively>, numargs=3, args=0x7ffcbd5c3b30) at ../../src/eval.c:3106
#32 0x0000000000694324 in Ffuncall (nargs=4, args=0x7ffcbd5c3b28) at ../../src/eval.c:3026
#33 0x00000000006eed2a in exec_byte_code (bytestr=XIL(0x7f23c129fd0c), vector=XIL(0x7f23c129f975), maxdepth=make_fixnum(13), args_template=make_fixnum(1025), nargs=1, args=0x7ffcbd5c40a0) at ../../src/bytecode.c:632
#34 0x0000000000694aec in fetch_and_exec_byte_code (fun=XIL(0x7f23c129f945), syms_left=make_fixnum(1025), nargs=1, args=0x7ffcbd5c4098) at ../../src/eval.c:3150
#35 0x0000000000694f72 in funcall_lambda (fun=XIL(0x7f23c129f945), nargs=1, arg_vector=0x7ffcbd5c4098) at ../../src/eval.c:3231
#36 0x0000000000694378 in Ffuncall (nargs=2, args=0x7ffcbd5c4090) at ../../src/eval.c:3030
#37 0x0000000000693c41 in call1 (fn=XIL(0x43e0), arg1=XIL(0x7f23c09fcab8)) at ../../src/eval.c:2886
#38 0x00000000005b5298 in command_loop_1 () at ../../src/keyboard.c:1505
#39 0x000000000068fdd6 in internal_condition_case (bfun=0x5b4a3f <command_loop_1>, handlers=XIL(0x90), hfun=0x5b3ec1 <cmd_error>) at ../../src/eval.c:1453
#40 0x00000000005b4624 in command_loop_2 (handlers=XIL(0x90)) at ../../src/keyboard.c:1133
#41 0x000000000068f05b in internal_catch (tag=XIL(0xe370), func=0x5b45fd <command_loop_2>, arg=XIL(0x90)) at ../../src/eval.c:1184
#42 0x00000000005b45c8 in command_loop () at ../../src/keyboard.c:1111
#43 0x00000000005b398c in recursive_edit_1 () at ../../src/keyboard.c:720
#44 0x00000000005b3ba0 in Frecursive_edit () at ../../src/keyboard.c:803
#45 0x00000000005afa5b in main (argc=5, argv=0x7ffcbd5c45a8) at ../../src/emacs.c:2310

Lisp Backtrace:
"delete-other-windows-internal" (0xbd5c2870)
"delete-other-windows" (0xbd5c2de0)
"let" (0xbd5c3100)
"cond" (0xbd5c3290)
"let*" (0xbd5c3450)
"window-toggle-side-windows" (0xbd5c3880)
"funcall-interactively" (0xbd5c3878)
"call-interactively" (0xbd5c3b30)
"command-execute" (0xbd5c4098)


I'll try to look into what goes wrong here as soon as I understand what
that assertion really means.  I suppose yours is an optimized build so
the assertion won't trigger.

Please make sure to always CC to 51007@debbugs.gnu.org.

Many thanks, martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-09 18:57         ` martin rudalics
@ 2021-10-10  6:20           ` Eli Zaretskii
  2021-10-10  8:58             ` martin rudalics
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2021-10-10  6:20 UTC (permalink / raw)
  To: martin rudalics; +Cc: 51007, indrajeet.khandekar

> From: martin rudalics <rudalics@gmx.at>
> Date: Sat, 9 Oct 2021 20:57:52 +0200
> Cc: 51007@debbugs.gnu.org
> 
> #0  0x00000000005acb54 in terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at ../../src/emacs.c:400
> #1  0x000000000065acc7 in die (msg=0x786590 "r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA] && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]", file=0x78629b "../../src/dispnew.c", line=1899) at ../../src/alloc.c:7478
> #2  0x000000000041cfab in fake_current_matrices (window=XIL(0x2444a2d)) at ../../src/dispnew.c:1898
> #3  0x000000000041ce37 in fake_current_matrices (window=XIL(0x252e995)) at ../../src/dispnew.c:1882
> #4  0x000000000041d7ba in adjust_frame_glyphs_for_frame_redisplay (f=0x24447e8) at ../../src/dispnew.c:2111
> #5  0x000000000041cd11 in adjust_frame_glyphs (f=0x24447e8) at ../../src/dispnew.c:1838
> 
> I'll try to look into what goes wrong here as soon as I understand what
> that assertion really means.

It's a basic sanity check that makes sure the window you are deleting
indeed belongs to the frame you think it does.  Since on TTY frames
the window glyph matrices are actually portions of the frame glyph
matrix, this assertion makes sure the window's glyphs of a row are
completely enclosed in the corresponding frame's glyphs.

What are the actual values of the data in this assertion:

	      eassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA]
		       && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]);





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10  6:20           ` Eli Zaretskii
@ 2021-10-10  8:58             ` martin rudalics
  2021-10-10  9:48               ` martin rudalics
  2021-10-10 10:55               ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: martin rudalics @ 2021-10-10  8:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 51007, indrajeet.khandekar

 > What are the actual values of the data in this assertion:
 >
 > 	      eassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA]
 > 		       && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]);

How would I do that?  These are structures like

(gdb) p r->glyphs[TEXT_AREA]
$1 = (struct glyph *) 0xe2df90
(gdb) p fr->glyphs[TEXT_AREA]
$2 = (struct glyph *) 0xe36690

BTW, the bug is easily reproducible using the following scenario: With
a master emacs -Q in an -nw session I evaluate

(setq display-buffer-alist
       '(("\\*Info\\*" (display-buffer-in-side-window) (side . right))
         ("\\*Help\\*" (display-buffer-in-side-window) (side . top))))

If I then do

C-x 3
C-h m

and evaluate

(delete-other-windows (window-main-window))

I get the assertion violation.  If instead I do

C-x 3
C-h m
C-h i

and evaluate

(delete-other-windows (window-main-window))

Emacs hangs in redisplay.  And if instead I do

C-x 3
C-h i

and evaluate

(delete-other-windows (window-main-window))

Emacs behaves as expected.

I suppose 'delete-other-windows-internal' mangles the window dimensions
but the scenarios work on GUI frames and pass all internal checks here
so it will take me some time to sort this out ...

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10  8:58             ` martin rudalics
@ 2021-10-10  9:48               ` martin rudalics
  2021-10-10 10:55               ` Eli Zaretskii
  1 sibling, 0 replies; 14+ messages in thread
From: martin rudalics @ 2021-10-10  9:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 51007, indrajeet.khandekar

 > I suppose 'delete-other-windows-internal' mangles the window dimensions
 > but the scenarios work on GUI frames and pass all internal checks here
 > so it will take me some time to sort this out ...

It indeed mangles the window dimensions in terms of lines and columns.
The Lisp routines to assign those run with a not yet updated window
tree.  So don't bother trying to reproduce it.

martin







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10  8:58             ` martin rudalics
  2021-10-10  9:48               ` martin rudalics
@ 2021-10-10 10:55               ` Eli Zaretskii
  2021-10-10 12:31                 ` martin rudalics
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2021-10-10 10:55 UTC (permalink / raw)
  To: martin rudalics; +Cc: 51007, indrajeet.khandekar

> Cc: indrajeet.khandekar@taranawireless.com, 51007@debbugs.gnu.org
> From: martin rudalics <rudalics@gmx.at>
> Date: Sun, 10 Oct 2021 10:58:12 +0200
> 
>  > What are the actual values of the data in this assertion:
>  >
>  > 	      eassert (r->glyphs[TEXT_AREA] >= fr->glyphs[TEXT_AREA]
>  > 		       && r->glyphs[LAST_AREA] <= fr->glyphs[LAST_AREA]);
> 
> How would I do that?  These are structures like
> 
> (gdb) p r->glyphs[TEXT_AREA]
> $1 = (struct glyph *) 0xe2df90
> (gdb) p fr->glyphs[TEXT_AREA]
> $2 = (struct glyph *) 0xe36690

These are the values I meant: the above shows the window's glyph
matrix and the frame's glyph matrix are unrelated.  Not sure how that
happened; perhaps one of them was recently reallocated?

> BTW, the bug is easily reproducible using the following scenario: With
> a master emacs -Q in an -nw session I evaluate

So you want me to debug it?

> I suppose 'delete-other-windows-internal' mangles the window dimensions
> but the scenarios work on GUI frames and pass all internal checks here
> so it will take me some time to sort this out ...

On GUI frames, the window's glyph matrices are allocated separately
and there's no frame glyph matrix to begin with.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10 10:55               ` Eli Zaretskii
@ 2021-10-10 12:31                 ` martin rudalics
  2021-10-10 13:09                   ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: martin rudalics @ 2021-10-10 12:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 51007, indrajeet.khandekar

 >> How would I do that?  These are structures like
 >>
 >> (gdb) p r->glyphs[TEXT_AREA]
 >> $1 = (struct glyph *) 0xe2df90
 >> (gdb) p fr->glyphs[TEXT_AREA]
 >> $2 = (struct glyph *) 0xe36690
 >
 > These are the values I meant: the above shows the window's glyph
 > matrix and the frame's glyph matrix are unrelated.  Not sure how that
 > happened; perhaps one of them was recently reallocated?

IIUC these are the beginning of the root's and the frame's text areas
where on TTYs the former must be embedded in the latter (1) when mapped
to the screen and (2) within the memory of my computer.  So if the root
matrix starts before the frame matrix in my memory I have a bug.  Is
that interpretation correct?

 >> BTW, the bug is easily reproducible using the following scenario: With
 >> a master emacs -Q in an -nw session I evaluate
 >
 > So you want me to debug it?

Don't bother.  The culprit sits in 'delete-other-windows-internal'.  I
apparently was just lucky that the assertion error triggered in one
scenario while in the other scenario Emacs somehow bypassed that check,
went into redisplay with bogus values and just got hung.

 >> I suppose 'delete-other-windows-internal' mangles the window dimensions
 >> but the scenarios work on GUI frames and pass all internal checks here
 >> so it will take me some time to sort this out ...
 >
 > On GUI frames, the window's glyph matrices are allocated separately
 > and there's no frame glyph matrix to begin with.

Which means that my first scenario cannot happen on GUIs.  I'm still
surprised that GUI frames apparently swallow quite a number of bogus
values without serious implications.

martin






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10 12:31                 ` martin rudalics
@ 2021-10-10 13:09                   ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2021-10-10 13:09 UTC (permalink / raw)
  To: martin rudalics; +Cc: 51007, indrajeet.khandekar

> Cc: indrajeet.khandekar@taranawireless.com, 51007@debbugs.gnu.org
> From: martin rudalics <rudalics@gmx.at>
> Date: Sun, 10 Oct 2021 14:31:06 +0200
> 
>  >> How would I do that?  These are structures like
>  >>
>  >> (gdb) p r->glyphs[TEXT_AREA]
>  >> $1 = (struct glyph *) 0xe2df90
>  >> (gdb) p fr->glyphs[TEXT_AREA]
>  >> $2 = (struct glyph *) 0xe36690
>  >
>  > These are the values I meant: the above shows the window's glyph
>  > matrix and the frame's glyph matrix are unrelated.  Not sure how that
>  > happened; perhaps one of them was recently reallocated?
> 
> IIUC these are the beginning of the root's and the frame's text areas
> where on TTYs the former must be embedded in the latter (1) when mapped
> to the screen and (2) within the memory of my computer.  So if the root
> matrix starts before the frame matrix in my memory I have a bug.  Is
> that interpretation correct?

Yes, AFAIU.
>  >> I suppose 'delete-other-windows-internal' mangles the window dimensions
>  >> but the scenarios work on GUI frames and pass all internal checks here
>  >> so it will take me some time to sort this out ...
>  >
>  > On GUI frames, the window's glyph matrices are allocated separately
>  > and there's no frame glyph matrix to begin with.
> 
> Which means that my first scenario cannot happen on GUIs.  I'm still
> surprised that GUI frames apparently swallow quite a number of bogus
> values without serious implications.

I think they just don't check, because there's no way of checking
that, unlike on TTY frames.  Glyph matrices of windows on GUI frames
are completely independent, and GUI frames don't have glyph matrices.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
       [not found]       ` <6D2FC628-BF92-4C35-8552-FBBEF0C7FDDC@taranawireless.com>
  2021-10-09 18:57         ` martin rudalics
@ 2021-10-10 17:16         ` martin rudalics
  2021-10-12  8:11           ` martin rudalics
  1 sibling, 1 reply; 14+ messages in thread
From: martin rudalics @ 2021-10-10 17:16 UTC (permalink / raw)
  To: Indrajeet Khandekar; +Cc: 51007

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

Indrajeet

I think I have fixed this here.  Basically, the bug totally breaks the
behavior with -nw but only partially breaks the gui behavior.  In the
latter case, parts of the window structure are corrupted but apparently
these do not substantially inhibit working with Emacs here.  It's not
excluded though, that the NS port fails in the gui case as well.

I attach two fixes for this:

- window.c.diff is the one I intend to install on Emacs 28 soon.

- window-27.diff is one you can install for Emacs 27 provided you are
   able to build Emacs on your system.  It includes the window.el patch
   which is already on Emacs 28.  If you can't build Emacs yourself, I'm
   afraid you have to wait for the new release.

Good luck and many thanks for the forensics, martin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: window.c.diff --]
[-- Type: text/x-patch; name="window.c.diff", Size: 3638 bytes --]

diff --git a/src/window.c b/src/window.c
index a6e8ee0d53..150c717ce8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3194,8 +3194,10 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
 window-start value is reasonable when this function is called.  */)
      (Lisp_Object window, Lisp_Object root)
 {
-  struct window *w, *r, *s;
-  struct frame *f;
+  struct window *w = decode_valid_window (window);
+  struct window *r, *s;
+  Lisp_Object frame = w->frame;
+  struct frame *f = XFRAME (frame);
   Lisp_Object sibling, pwindow, delta;
   Lisp_Object swindow UNINIT;
   ptrdiff_t startpos UNINIT, startbyte UNINIT;
@@ -3203,9 +3205,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
   int new_top;
   bool resize_failed = false;

-  w = decode_valid_window (window);
   XSETWINDOW (window, w);
-  f = XFRAME (w->frame);

   if (NILP (root))
     /* ROOT is the frame's root window.  */
@@ -3245,7 +3245,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
       /* Make sure WINDOW is the frame's selected window.  */
       if (!EQ (window, FRAME_SELECTED_WINDOW (f)))
 	{
-	  if (EQ (selected_frame, w->frame))
+	  if (EQ (selected_frame, frame))
 	    Fselect_window (window, Qnil);
 	  else
 	    /* Do not clear f->select_mini_window_flag here.  If the
@@ -3278,7 +3278,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,

       if (!EQ (swindow, FRAME_SELECTED_WINDOW (f)))
 	{
-	  if (EQ (selected_frame, w->frame))
+	  if (EQ (selected_frame, frame))
 	    Fselect_window (swindow, Qnil);
 	  else
 	    fset_selected_window (f, swindow);
@@ -3313,18 +3313,12 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
       w->top_line = r->top_line;
       resize_root_window (window, delta, Qnil, Qnil, Qt);
       if (window_resize_check (w, false))
-	{
-	  window_resize_apply (w, false);
-	  window_pixel_to_total (w->frame, Qnil);
-	}
+	window_resize_apply (w, false);
       else
 	{
 	  resize_root_window (window, delta, Qnil, Qt, Qt);
 	  if (window_resize_check (w, false))
-	    {
-	      window_resize_apply (w, false);
-	      window_pixel_to_total (w->frame, Qnil);
-	    }
+	    window_resize_apply (w, false);
 	  else
 	    resize_failed = true;
 	}
@@ -3337,18 +3331,12 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
 	  XSETINT (delta, r->pixel_width - w->pixel_width);
 	  resize_root_window (window, delta, Qt, Qnil, Qt);
 	  if (window_resize_check (w, true))
-	    {
-	      window_resize_apply (w, true);
-	      window_pixel_to_total (w->frame, Qt);
-	    }
+	    window_resize_apply (w, true);
 	  else
 	    {
 	      resize_root_window (window, delta, Qt, Qt, Qt);
 	      if (window_resize_check (w, true))
-		{
-		  window_resize_apply (w, true);
-		  window_pixel_to_total (w->frame, Qt);
-		}
+		window_resize_apply (w, true);
 	      else
 		resize_failed = true;
 	    }
@@ -3390,6 +3378,12 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
     }

   replace_window (root, window, true);
+  /* Assign new total sizes to all windows on FRAME.  We can't do that
+     _before_ WINDOW replaces ROOT since 'window--pixel-to-total' works
+     on the whole frame and thus would work on the frame's old window
+     configuration (Bug#51007).  */
+  window_pixel_to_total (frame, Qnil);
+  window_pixel_to_total (frame, Qt);

   /* This must become SWINDOW anyway .......  */
   if (BUFFERP (w->contents) && !resize_failed)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: window-27.diff --]
[-- Type: text/x-patch; name="window-27.diff", Size: 2459 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index 95db01bca4..b844e8d17a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1192,7 +1192,8 @@ window-toggle-side-windows
      ((setq state (frame-parameter frame 'window-state))
       ;; A window state was saved for FRAME.  Restore it and put the
       ;; current root window into its main window.
-      (let ((main-state (window-state-get (frame-root-window frame))))
+      (let ((window-combination-resize t)
+            (main-state (window-state-get (frame-root-window frame))))
         (window-state-put state (frame-root-window frame) t)
         (window-state-put main-state (window-main-window frame)))
       (window--sides-reverse-frame frame))
diff --git a/src/window.c b/src/window.c
index f231187f7b..71c0d91ab2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3296,7 +3296,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
       if (window_resize_check (w, false))
 	{
 	  window_resize_apply (w, false);
-	  window_pixel_to_total (w->frame, Qnil);
+/** 	  window_pixel_to_total (w->frame, Qnil); **/
 	}
       else
 	{
@@ -3304,7 +3304,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
 	  if (window_resize_check (w, false))
 	    {
 	      window_resize_apply (w, false);
-	      window_pixel_to_total (w->frame, Qnil);
+/** 	      window_pixel_to_total (w->frame, Qnil); **/
 	    }
 	  else
 	    resize_failed = true;
@@ -3320,7 +3320,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
 	  if (window_resize_check (w, true))
 	    {
 	      window_resize_apply (w, true);
-	      window_pixel_to_total (w->frame, Qt);
+/** 	      window_pixel_to_total (w->frame, Qt); **/
 	    }
 	  else
 	    {
@@ -3328,7 +3328,7 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
 	      if (window_resize_check (w, true))
 		{
 		  window_resize_apply (w, true);
-		  window_pixel_to_total (w->frame, Qt);
+/** 		  window_pixel_to_total (w->frame, Qt); **/
 		}
 	      else
 		resize_failed = true;
@@ -3371,6 +3371,8 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
     }

   replace_window (root, window, true);
+  window_pixel_to_total (w->frame, Qnil);
+  window_pixel_to_total (w->frame, Qt);

   /* This must become SWINDOW anyway .......  */
   if (BUFFERP (w->contents) && !resize_failed)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* bug#51007: 27.2; emacs hangs when using window-toggle-side-windows
  2021-10-10 17:16         ` martin rudalics
@ 2021-10-12  8:11           ` martin rudalics
  0 siblings, 0 replies; 14+ messages in thread
From: martin rudalics @ 2021-10-12  8:11 UTC (permalink / raw)
  To: Indrajeet Khandekar; +Cc: 51007

close 51007 28.1
quit

 > I attach two fixes for this:
 >
 > - window.c.diff is the one I intend to install on Emacs 28 soon.

This has been installed on the release branch for Emacs 28.1.  Closing
this bug now; if there are any problems please reopen.

Thanks, martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-10-12  8:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 13:36 bug#51007: 27.2; emacs hangs when using window-toggle-side-windows Indrajeet Khandekar
2021-10-04 18:22 ` martin rudalics
     [not found]   ` <01944062-1C37-4B9A-98B9-F79F29D3B8F4@taranawireless.com>
2021-10-05  8:09     ` martin rudalics
2021-10-05 10:53   ` Indrajeet Khandekar
2021-10-05 12:37     ` martin rudalics
     [not found]       ` <6D2FC628-BF92-4C35-8552-FBBEF0C7FDDC@taranawireless.com>
2021-10-09 18:57         ` martin rudalics
2021-10-10  6:20           ` Eli Zaretskii
2021-10-10  8:58             ` martin rudalics
2021-10-10  9:48               ` martin rudalics
2021-10-10 10:55               ` Eli Zaretskii
2021-10-10 12:31                 ` martin rudalics
2021-10-10 13:09                   ` Eli Zaretskii
2021-10-10 17:16         ` martin rudalics
2021-10-12  8:11           ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).