sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

crash when hiding the overlay in on_query_context #2080

Open evandrocoan opened 6 years ago

evandrocoan commented 6 years ago

While writing a package to fix the issue:

  1. https://github.com/SublimeTextIssues/Core/issues/1814 Command palette cleans the last command on escape key press

I found out this this minimal code to be crashing Sublime Text.

Steps to reproduce

  1. Open a Sublime Text vanilla install
  2. Create the package Packages/Test
  3. Create the file Packages/Test/test.py

    import sublime
    import sublime_plugin
    
    class FixedCommandPaletteLastInputHistoryCommand(sublime_plugin.WindowCommand):
    
       def run(self):
           self.window.run_command( "show_overlay", {"overlay": "command_palette"} )
    
    class FixedCommandPaletteLastInputHistoryEventListener(sublime_plugin.EventListener):
    
       def on_query_context(self, view, key, operator, operand, match_all):
    
           if key == "fixed_command_palette_last_input_history_context":
               view.window().run_command( "hide_overlay" )
               return True
    
           return None
  4. Create the file Packages/Text/Default.sublime-keymap
    [
       { "keys": ["ctrl+shift+p"], "command": "fixed_command_palette_last_input_history", 
           "context":
           [
               { "key": "fixed_command_palette_last_input_history_context" }
           ]
       },
    ]
  5. Press Ctrl+Shift+P to open the command palette.
  6. While keeping the command palette open, press again Ctrl+Shift+P, Sublime Text will crash.

Environment


Here are my dump file from the vanilla install, while writing the minimal code for this issue:

  1. f88a6943-cfac-4b7c-8530-a3494f0a7745.zip
  2. 5e553c8a-738d-4260-b82c-a62c097ce003.zip
  3. 6e213a6e-a2b3-4296-a5ff-4212b986c47c.zip
  4. 09f9d38a-bbdb-481a-b3c3-b7fd270c6771.zip
  5. bab7b9b1-ffa7-4106-9428-67d7368aee9a.zip
    
    Dump Summary
    ------------
    Dump File:  5e553c8a-738d-4260-b82c-a62c097ce003.dmp : D:\SublimeText\Old Builds\3156\5e553c8a-738d-4260-b82c-a62c097ce003.dmp
    Last Write Time:    02-Dec-17 16:15:29
    Process Name:   sublime_text.exe : D:\SublimeText\Old Builds\3156\sublime_text.exe
    Process Architecture:   x86
    Exception Code: 0xC0000005
    Exception Information:  The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
    Heap Information:   Not Present

System Information

OS Version: 10.0.15063 CLR Version(s):

keith-hall commented 6 years ago

on_query_context is probably not supposed to have side-effects, writing plugins that do such could well be unsupported.