Skip to content

Persistent data notifications from Rust API #7890

@emesare

Description

@emesare

Current state of data notifications in Rust API:

let custom = DataNotificationClosure::default()
.function_updated(|_bv: &BinaryView, _func: &Function| {
func_updated_count += 1;
})
.register(&bv);
let crash = bv.create_tag_type("Test", "🚧");
let funcs = bv.functions();
for func in &funcs {
func.add_tag(
&crash,
"Dummy tag",
Some(10.try_into().unwrap()),
true,
None,
);
}
custom.unregister();

The custom is of type DataNotificationHandle which is defined as:

pub struct DataNotificationHandle<'a, T: CustomDataNotification>
where
T: 'a,
{
bv: Ref<BinaryView>,
handle: Box<BNBinaryDataNotification>,
_life: std::marker::PhantomData<&'a T>,
}

This means that we are holding a strong reference to the view (for the purposes of dropping the data notification when custom is dropped) which inhibits the ability to leak the custom handle to persist the data notifications, we need to address this somehow to make using data notifications in Rust API more user friendly and less of a footgun.

One idea would be to provide an alternate register API that does not return a handle containing a strong reference to the view, or instead hold a weak reference to the view, but that is very difficult to do.

See this example for a motivating reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Rust APIIssue needs changes to the Rust APIEffort: TrivialIssues require < 1 day of workImpact: MediumIssue is impactful with a bad, or no, workaround

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions