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

vm: fix leak in vm.compileFunction when importModuleDynamically is used #46785

Closed

Commits on Feb 23, 2023

  1. vm: fix leak in vm.compileFunction when importModuleDynamically is used

    Previously in the implementation there was a cycle that V8 could not
    detect:
    
    Strong global reference to CompiledFnEntry (JS wrapper)
        -> strong reference to callback setting (through the
           callbackMap key-value pair)
        -> importModuleDynamically (wrapper in internalCompileFunction())
        -> Strong reference to the compiled function (through closure in
           internalCompileFunction())
    
    The CompiledFnEntry only gets GC'ed when the compiled function is GC'ed.
    Since the compiled function is always reachable as described above,
    there is a leak.
    
    We only needed the first strong global reference because we didn't want
    the function to outlive the CompiledFnEntry. In this case it can be
    solved by using a private symbol instead of going with the global
    reference + destruction in the weak callback, which V8's GC is not
    going to understand.
    joyeecheung committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    219c771 View commit details
    Browse the repository at this point in the history