cs431 icon indicating copy to clipboard operation
cs431 copied to clipboard

[Homework 3] Core Arc (due: 2024-04-14 23:59:59)

Open kingdoctor123 opened this issue 1 year ago • 2 comments

Implement a simplified version of Arc.

  • Read this manual for general advice on homework.

  • Documentation & Tips.

  • Use skeleton code as a starting point, and fill out todo!().

    • IMPORTANT: don't fork this repository. It'll be public!
  • Submit your code here.

  • IMPORTANT: Only the last submission counts. Please make sure the last line of the "log" says "Score: ?? / ??".

kingdoctor123 avatar Feb 27 '24 11:02 kingdoctor123

When running tests with cargo_asan test --doc arc, I encountered an error indicating a memory leak. However, in the case of try_unwrap, if the Arc is unique, isn't it expected to have a memory leak?

leeyh0623 avatar Apr 09 '24 21:04 leeyh0623

Without looking at real code, it is really difficult to find out the reason for having memory leaks since there are lots of sources for memory leaks. But even if Arc is unique, your implementation may have memory leak if you incorrectly understand Rust's semantics for dropping an object. For example, one example of incorrect implementation of try_unwrap might leave some contents of Arc (e.g. count) unallocated forever even if try_unwrap successfully returns the inner value and the inner value has been dropped by the caller.

kingdoctor123 avatar Apr 10 '24 05:04 kingdoctor123