diff --git a/bytehook/src/main/cpp/bh_elf_manager.c b/bytehook/src/main/cpp/bh_elf_manager.c index 830cfd2..e9d19de 100644 --- a/bytehook/src/main/cpp/bh_elf_manager.c +++ b/bytehook/src/main/cpp/bh_elf_manager.c @@ -200,9 +200,6 @@ void bh_elf_manager_refresh(bh_elf_manager_t *self, bool sync_clean, bh_elf_mana } } - // unlock ELFs-tree - pthread_rwlock_unlock(&self->elfs_lock); - // if we are in sync-clean status, no other iterate or hooks can be performed at the same time if (sync_clean) { // remove and destroy all unreferenced ELF object in the abandoned list @@ -212,6 +209,9 @@ void bh_elf_manager_refresh(bh_elf_manager_t *self, bool sync_clean, bh_elf_mana } } + // unlock ELFs-tree + pthread_rwlock_unlock(&self->elfs_lock); + // do callback for newborn ELFs (no need to lock) if (NULL != cb) { TAILQ_FOREACH_SAFE(elf, &new_elfs, link_list, elf_tmp) {