-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
findjsobjects -r should cleanup referents tree when appropriate #80
Comments
Does the following approach: diff --git a/src/mdb_v8.c b/src/mdb_v8.c
index 1227c85..f65d114 100644
--- a/src/mdb_v8.c
+++ b/src/mdb_v8.c
@@ -5099,13 +5099,25 @@ findjsobjects_referent(findjsobjects_state_t *fjs, uintptr_t addr)
}
static void
+findjsobjects_referents_destroy(findjsobjects_state_t *fjs)
+{
+ avl_tree_t *referents = &fjs->fjs_referents;
+ findjsobjects_referent_t *referent;
+ void *cookie = NULL;
+
+ while ((referent = avl_destroy_nodes(referents, &cookie)) != NULL)
+ mdb_free(referent, sizeof (findjsobjects_referent_t));
+
+ fjs->fjs_head = NULL;
+ fjs->fjs_tail = NULL;
+}
+
+static void
findjsobjects_references(findjsobjects_state_t *fjs)
{
findjsobjects_reference_t *reference;
findjsobjects_referent_t *referent;
- avl_tree_t *referents = &fjs->fjs_referents;
findjsobjects_obj_t *obj;
- void *cookie = NULL;
uintptr_t addr;
fjs->fjs_referred = B_FALSE;
@@ -5164,11 +5176,7 @@ findjsobjects_references(findjsobjects_state_t *fjs)
/*
* Finally, destroy our referent nodes.
*/
- while ((referent = avl_destroy_nodes(referents, &cookie)) != NULL)
- mdb_free(referent, sizeof (findjsobjects_referent_t));
-
- fjs->fjs_head = NULL;
- fjs->fjs_tail = NULL;
+ findjsobjects_referents_destroy(fjs);
}
static findjsobjects_instance_t *
@@ -5560,6 +5568,15 @@ dcmd_findjsobjects(uintptr_t addr,
return (DCMD_OK);
}
+ if (!fjs->fjs_marking) {
+ /*
+ * Destroy all referents added by previous marking
+ * commands before adding new referents for this
+ * non-marking command invocation.
+ */
+ findjsobjects_referents_destroy(fjs);
+ }
+
if (!listlike) {
findjsobjects_referent(fjs, inst->fjsi_addr);
} else { make sense? If so I'll submit a PR asap with tests and maybe a few extra assertions. |
I did not know that "findjsobjects -m" existed, and had trouble understanding what it does. If I'm understanding correctly, it's intended as a way to do "ADDR::findjsobjects -r" for several addresses in the same search. So the idea is that if you would run:
then this would be equivalent, but require only one scan:
If I'm understanding that correctly, then it's working as intended (the referents tree is supposed to stick around), and the proposed solution would break that behavior. The fact that there's no way to list marked objects, remove them, or even clear them makes me wonder if I'm misunderstanding, though. Maybe you're supposed to use |
I believe that is correct. It is (and was) my understanding as well.
I don't think the proposal would break the behavior described above. The proposal clears the tree of referents only when the explicit (when specifying an address) form of Here's an example that illustrates the behavior of a version of mdb_v8 built locally with the proposed changes:
The resulting behavior is what we expected, and a subsequent
The problem that I'm trying to solve is that, when running the following two commands in sequence:
mdb_v8 currently aborts, which is not the expected and desired behavior. The proposed changes solve this problem by assuming that, if the user specifies an address when running This is one approach, there are other different approaches possible, including:
What is the approach that seems the most reasonable to you? |
I think your proposal is fine. Just to clarify, we only clear the tree if you explicitly specify an address to "::findjsobjects -r". As we discussed, I think it would be worth printing a message when we remove anything in this case. |
When marking objects as referents with
::findjsobjects -m
and then performing a search for references on a given referent with theaddr::findjsobjects -r
command form, mdb_v8 aborts due to an assertion:The reason is that, when executing the
addr::findjsobjects -r
form, mdb_v8 does not destroy the tree of referents that may have been built during a previous run of::findjsobjects -m
before adding new referents.My proposed solution is that if
-m
is not passed to::findjsobjects
, we can destroy the tree of referents before adding new referents.Successive runs of
::findjsobjects -m
can still accumulate referents, but as soon as a non-marking::findjsobjects
command is used, the tree of referents is cleared.The text was updated successfully, but these errors were encountered: