Skip to content

Commit 0cccd4e

Browse files
committed
Fix referring to deleted buffer, by deleting it
The comment explains, badly, that there is a bug somewhere that when we wipe out the disassembly buffers, we end up with: || Caught exception in Test_Disassembly_Open_Close(): Vim(py3):vim.error: Vim(py3):vim.error: attempt to refer to deleted buffer But I can't work out why exactly. Wiping out the buffer causes this, but deleting the buffer doesn't.
1 parent b9ee68b commit 0cccd4e

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

python3/vimspector/debug_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def SwitchFrom( self ):
552552

553553
def OnChannelData( self, data ):
554554
if self._connection is None:
555-
# Should _not_ happen, but maybe possible due to races or vim bufs?
555+
# Should _not_ happen, but maybe possible due to races or vim bugs?
556556
return
557557

558558
self._connection.OnData( data )

python3/vimspector/disassembly.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,18 @@ def Reset( self ):
173173

174174
self._buf = None
175175
for b in self._scratch_buffers:
176-
utils.CleanUpHiddenBuffer( b )
176+
# FIXME/TODO: Unknown hack :(
177+
# For some reason I can't work out if the buffer is wiped out here, we
178+
# get a test failure in Test_Disassembly_Open_Close.
179+
# Initially I thought it was because _scratch_buffers might contain
180+
# duplicates, but changing it to a set() doesn't help, so it's not that.
181+
# What seems to happen is we get data on the socket/channel and the
182+
# callback tries to do something with the wiped-out buffer.
183+
#
184+
# Unfortunately I can't fathom what's happening, so hacking this
185+
# wipeout=False for now to make the tests pass. Yes, I'll suffer in
186+
# purgatory for that.
187+
utils.CleanUpHiddenBuffer( b, wipeout=False )
177188

178189
self._scratch_buffers = []
179190

python3/vimspector/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,16 @@ def CleanUpCommand( session_id, name, api_prefix ):
161161
name ) )
162162

163163

164-
def CleanUpHiddenBuffer( buf ):
164+
def CleanUpHiddenBuffer( buf, wipeout=True ):
165165
if not buf.valid:
166166
return
167167

168+
cmd = 'bwipeout' if wipeout else 'bdelete'
169+
168170
try:
169-
vim.command( 'bwipeout! {}'.format( buf.number ) )
171+
vim.command( '{}! {}'.format( cmd, buf.number ) )
170172
except vim.error as e:
171-
if 'E517' not in str( e ):
173+
if 'E517' not in str( e ) and 'E516' not in str( e ):
172174
raise
173175

174176

0 commit comments

Comments
 (0)