Skip to content
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

Should findrefs display context/scope objects? #195

Closed
mmarchini opened this issue May 8, 2018 · 5 comments
Closed

Should findrefs display context/scope objects? #195

mmarchini opened this issue May 8, 2018 · 5 comments

Comments

@mmarchini
Copy link
Contributor

  • Version: llnode 1.7.0, node v8.11.1
  • Platform: OS X (10.13.4)
  • Subsystem: findrefs

Let's say we have an object which is not referenced by any other objects, but is scoped by a function or by a script. Should v8 findrefs [obj addr] return nothing (current behavior), or should it return the scope this object belongs to? IMO we should change the behavior to return the scope as well, because looking at the output from the example below it seems like there are Lero instances leaking, even though it's not true.

Example:

index.js

class Lero {
  constructor() {
    this.lala = {};
  }
}

class Lira {
  constructor() {
    this.lele = {};
  }
}


const lero = new Lero();

function foo() {
  const lero2 = new Lero();
  boom();
}

foo();

llnode results

(llnode) v8 findjsinstances -d Lero
0x00000548a34200e1:<Object: Lero properties {
    .constructor=<unknown field type>}>
0x00000548a3420589:<Object: Lero properties {
    .lala=0x00000548a34205e9:<Object: Object>}>
0x00000548a3420659:<Object: Lero properties {
    .lala=0x00000548a34206b9:<Object: Object>}>
(llnode) v8 findrefs 0x00000548a3420589
(llnode) v8 findrefs 0x00000548a3420659
@bnoordhuis
Copy link
Member

Including the owning context(s) in the output sounds like a good idea to me.

@joyeecheung
Copy link
Member

SGTM, otherwise one will hit a dead end with objects like that.

Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
@Drieger
Copy link
Contributor

Drieger commented Sep 4, 2018

A just created a PR llnode/pull/227 to approach this issue. It seems that some Function-Variables are not referenced by any Context unless a nested closure references it.

The idea is to store all contexts and look in each one when we try to find references for an object.

Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
Drieger added a commit to Drieger/llnode that referenced this issue Sep 12, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
Drieger added a commit to Drieger/llnode that referenced this issue Sep 17, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195
joyeecheung pushed a commit that referenced this issue Sep 25, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: #195

PR-URL: #227
Reviewed-By: Matheus Marchini <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
hyj1991 pushed a commit to aliyun-node/llnode that referenced this issue Sep 26, 2018
When using `findrefs` we should be able to get all references
for the given value, this includes `Context` objects.

Refs: nodejs#195

PR-URL: nodejs#227
Reviewed-By: Matheus Marchini <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@watson
Copy link
Member

watson commented Apr 2, 2019

Wasn't this addressed in #227?

@mmarchini
Copy link
Contributor Author

Yes. I was keeping this open as a reminder to show stack locals in findrefs, but I'm not even sure it's possible. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants