kaist-cp / cs431

1.42k stars 135 forks source link

[Question] [Homework 6] debug_assert_eq for decomposed tag of shared pointer #326

Closed haeeun-14 closed 3 years ago

haeeun-14 commented 3 years ago
thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`assertion failed: `(left == right)`
  left: `1`,
 right: `0`', ', /home/s20160325/cs492-concur/homework/src/hazard_pointer/retire.rs/home/s20160325/cs492-concur/homework/src/hazard_pointer/retire.rs::3333::1313
       unsafe fn free<T>(data: usize) {
            debug_assert_eq!(align::decompose_tag::<T>(data).1, 0);
            drop(Box::from_raw(data as *mut T))
        }

This is part of the skeleton code. As I understand, the free function, a part of a element of the Retirees, is for freeing each element pointed by the pointer of in the Retirees. As this code gives error, I think I wrongly implemented the pointer somewhere in my code. But the retire function doesn't seem to appear in any other part of my code. Plus, I could not get the meaning of asserting that the decomposed tag is zero. If anyone know about this issue, can you please let me know?

hoyacj1 commented 3 years ago

I could not get the meaning of asserting that the decomposed tag is zero.

It means freeing pointer should be aligned. Maybe you didn't decompose the pointer somewhere(retire or collect or other functions).

haeeun-14 commented 3 years ago

Thank you for the help! The problem is solved.