Skip to content

Should findrefs display context/scope objects? #195

Closed

Description

@mmarchini
  • 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

Activity

  1. bnoordhuis commented on May 11, 2018

    @bnoordhuis
    Member

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

  2. joyeecheung commented on May 14, 2018

    @joyeecheung
    Member

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

  3. Drieger commented on Sep 4, 2018

    @Drieger
    Contributor

    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.

  4. watson commented on Apr 2, 2019

    @watson
    Member

    Wasn't this addressed in #227?

  5. mmarchini commented on Apr 2, 2019

    @mmarchini
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions