Skip to content

Comments

Fix uninitialized frame crashes#104

Merged
zenspider merged 3 commits intonex3:masterfrom
gcv:fix-uninitialized-frame-crashes
Nov 20, 2019
Merged

Fix uninitialized frame crashes#104
zenspider merged 3 commits intonex3:masterfrom
gcv:fix-uninitialized-frame-crashes

Conversation

@gcv
Copy link
Collaborator

@gcv gcv commented Oct 22, 2019

No description provided.

gcv added 3 commits October 10, 2019 10:38
These occur when persp-mode is active, but a frame is created with
after-make-frame-functions bypassed (i.e., let-bound to nil), resulting in
frames without frame parameters which persp-mode expects.

Since most of these errors occur in unguarded use of perspectives-hash,
persp-curr, and persp-last, this workaround tries to return reasonable but empty
values from these functions instead of nil.
@gcv gcv requested a review from zenspider October 22, 2019 21:41
@zenspider
Copy link
Collaborator

Can you 'splain how you get this to occur? I don't hit this ever.

@gcv
Copy link
Collaborator Author

gcv commented Oct 23, 2019

Start from a fresh Emacs instance. Make sure you don't have this patch or #86 loaded.

Evaluate:

(let ((after-make-frame-functions nil))
  (make-frame))

This pops open a new frame. Perspective is not enabled in this frame, and will break if you attempt to use it. This is expected behavior (although far from ideal), as after-make-frame-functions bound to nil suppresses the hooks which handle the creation of all frame parameters which perspective relies on.

Unfortunately, this also breaks perspective in the original frame in which all frame parameters are properly loaded. Keep the new frame open, go back to the original frame, make a new perspective, and then attempt to kill that new perspective. You'll get Wrong type argument: hash-table-p, nil.

This matters because posframe does exactly this when creating its frames. posframe-dependent packages create hidden frames, none of which have the necessary frame parameter initialization. Most notably, this breaks ivy-posframe. To add insult to injury, this is not debuggable with toggle-debug-on-error.

I wrote a test, but I can't get it to work properly in terminal mode Emacs: calling make-frame in a batch test run errors out with "Unknown terminal type".

(ert-deftest issue-104-errors-with-uninitialized-frames ()
  (persp-test-with-persp
   ;;(persp-switch "A")
   (let ((after-make-frame-functions nil))
     (let ((orig-frame (selected-frame))
           (new-frame (make-frame)))
       (with-selected-frame orig-frame
         (persp-switch "A")
         (persp-switch "main")
         ;; should not error out:
         (persp-kill "test"))))))

This PR is an alternative to #86, which — as you noted — is a much more invasive approach to solving this problem. (It also complements the overall cleanup of frame parameter use in #91, which I haven't had time to test.)

@gcv
Copy link
Collaborator Author

gcv commented Oct 27, 2019

@zenspider: Any thoughts on this?

@zenspider zenspider merged commit 29f4c5c into nex3:master Nov 20, 2019
@zenspider
Copy link
Collaborator

no thoughts. just merged. :P

@gcv gcv deleted the fix-uninitialized-frame-crashes branch November 26, 2019 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants