UEFI.pool_allocator.resize() Unreachable Code when length and capacity match on an ArrayList #21446
Labels
bug
Observed behavior contradicts documented or intended behavior
os-uefi
standard library
This issue involves writing Zig code for the standard library.
Milestone
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Working on a UEFI zig project and keep hitting a random panic when trying to get an ownedSlice from an arraylist. Eventually narrowed it down to only be occurring when capacity and length match on an array list. Manually incrementing the capacity by 1 causes the panic branch to be missed.
The following code will reliably hit the panic branch on my machine. I know its not perfect, pretty, or correct however, it does its job just fine. It could probably be cleaned up by a fair bit but this is what I was able to quickly throw together to get around the compiler optimizing away the code.
The code panics with the msg
reached unreachable code
. Digging around the code further revealed it to be caused by the resize method being performed in thetoOwnedSlice()
callallocator.resize(old_memory, self.items.len)
https://ziglang.org/documentation/master/std/#src/std/array_list.zig
Currently dont have any way to debug zig UEFI applications so this is as far as I was able to take this atm.
Expected Behavior
Standard library should not panic
The text was updated successfully, but these errors were encountered: