galloc icon indicating copy to clipboard operation
galloc copied to clipboard

Panic in 32bit environment

Open PegasisForever opened this issue 2 years ago • 0 comments

I'm trying to use galloc on a 32bit arm microcontroller. When initializing, the library panicked at 'attempt to subtract with overflow' at this line.

I did some debugging and I think I found the reason:

  • MIN_ALIGNMENT_LOG2 is the trailing zeros of MIN_ALIGNMENT, which has a minimum of 8.
  • largest_power_of_2_that_divides_addr comes from addr + HEADER_SIZE, which addr is aligned but HEADER_SIZE is not aligned due to its use of usize in the 32bit environment.
  • This causes 2 - 3 and triggers the panic.

I'd love to help testing the crate again if you make changes.

PegasisForever avatar May 10 '23 13:05 PegasisForever