Commit c128c2ed authored by Woosuk Kwon's avatar Woosuk Kwon
Browse files

Fix double free

parent c80ed212
......@@ -115,13 +115,13 @@ class BlockSpaceManager:
last_block = block_table[-1]
assert last_block.device == Device.GPU
if last_block.ref_count == 1:
# Append.
# Not shared with other sequences. Appendable.
return None
else:
# The last block is shared with other sequences.
# Copy on Write: Allocate a new block and copy the tokens.
new_block = self.gpu_allocator.allocate()
block_table.append(new_block)
block_table[-1] = new_block
self.gpu_allocator.free(last_block)
return last_block.block_number, new_block.block_number
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment