Skip to content

Commit

Permalink
Fixed crash in arena_free_all() for bootstrapped growing arenas.
Browse files Browse the repository at this point in the history
When trying to set arena.curr_block.used = 0 after mem.zero() caused a crash because if the arena is bootstrapped its memory will be zeroed out after mem.zero() thus making arena.cur_block point to zero.
  • Loading branch information
dmitriy.gorevoy committed Dec 23, 2024
1 parent 597fba7 commit e82a0c8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/mem/virtual/arena.odin
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ arena_free_all :: proc(arena: ^Arena, loc := #caller_location) {
}
// Zero the first block's memory
if arena.curr_block != nil {
mem.zero(arena.curr_block.base, int(arena.curr_block.used))
curr_block_used := int(arena.curr_block.used)
arena.curr_block.used = 0
mem.zero(arena.curr_block.base, curr_block_used)
}
arena.total_used = 0
case .Static, .Buffer:
Expand Down

0 comments on commit e82a0c8

Please sign in to comment.