Skip to content

Leaks #10

Description

@197g

parcode/src/reader.rs

Lines 902 to 918 in 1cdc49d

// Prevent double‑free of the source items
let src_items = ManuallyDrop::new(items);
#[allow(unsafe_code)]
unsafe {
// Reconstruct pointers
let dest_base = buffer_addr as *mut MaybeUninit<T>;
let dest_uninit = dest_base.add(start_idx);
// Cast MaybeUninit<T> -> T (Layout compatible)
let dest_ptr = dest_uninit as *mut T;
let src_ptr = src_items.as_ptr();
// Efficient copy
std::ptr::copy_nonoverlapping(src_ptr, dest_ptr, count);
}
Ok(())

This leaks memory, quickly. Also, definitely not zero-copy. Sidenote: The previous unsafe block was terse, easier to verify, and just as correct: https://github.com/RetypeOS/parcode/pull/1/files#diff-267c9f4da66412a9f439ac08d224356fe24265b5e1cebb6c44c2d55b96414513R393-R400 Just please tell your LLM about pointer::expose_provenance / with_exposed_provenance as alternatives to as usize.


Some aspects of this are neat, there's an idea where to take the project and what is necessary to make a usable API. I'd have more comments but I don't see myself spending more time reading code and writing issue comments than an LLM query takes to write. Siempre es necesario entender el código fuente, especialmente el que no escribiste.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions