fix: defer removed hook callback drops - #16
Conversation
e95b34d to
8414ded
Compare
Signed-off-by: Jvle <keke.oerv@isrc.iscas.ac.cn>
8414ded to
33a6bea
Compare
|
I'm not get what problem you want to solve. As you noticed unicorn does this already, so why do it again in the rust bindings? |
unicorns do exist in this way. However, in the rust bindings: Previously, when Therefore, the goal here is to ensure that both the rust callback and the unicorn hook are released at the same time. more easily example: let hook_id = Rc::new(Cell::new(None));
let hook = uc.add_code_hook(CODE_START, CODE_START, move |uc, _, _| {
// remove callback's hook
// The callback might be dropped early while it is executing,
// even though the lifetime of the hook has not yet ended.
uc.remove_hook(hook_id.get().unwrap()).unwrap();
uc.emu_start(CODE_START + 1, CODE_START + 2, 0, 0).unwrap();
}).unwrap();
hook_id.set(Some(hook));You can see here :> : unicorn-engine-rs/crates/unicorn/src/lib.rs Line 1188 in e8ca055 Original code: when a matching What is your take on this issue? :> Note: Also due to the delayed deallocation mechanism(In C API), unicorn's C core library still holds an internal |
This is a bug, when a hook is deleted it should not be called again. Can you test if unicorn-engine/unicorn#2253 fixes your issue? |
sure, I will reply here as soon as I have finished testing. |
Hello maintainers,
I noticed issues with the current hook mechanism and have therefore made the following modifications.
This mechanism introduces a nesting counter parameter and briefly retains removed hooks until it is confirmed that the simulation has concluded.
Note: a similar method already exists in the unicorn core.
see: