Skip to content

[Question] how to make it safe? #125

@hasezoey

Description

@hasezoey

i ask this here, because github discussions seem to not be enabled for this project


i am still quite new to rust and have no experience in c/c++ (or other low-level / systems languages), and with this project i have to use a lot of unsafe and i also read Unsafety, but i could not understand how i could make it (more) safe, especially the following part got me thinking on how to do it properly:

Rust documentation for Qptr:

It's still possible to cause use-after-free by calling a method through QPtr.
Even in a single threaded program, the accessed object can be deleted by a nested call
while one of its methods is still running. In multithreaded context, the object can be deleted
in another thread between the null check and the method call, also resulting in undefined
behavior.

so my question is: how can i make it safe if it may not be safe after having already checked (like with is_null)?
or how can i at least detect that it is wrong / malfunctioned and catch it to recover from it (like a Result in rust)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions