Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Leaking outside of optimized functions not supported #2386

Open
NTillmann opened this issue Aug 3, 2018 · 0 comments
Open

Leaking outside of optimized functions not supported #2386

NTillmann opened this issue Aug 3, 2018 · 0 comments
Assignees

Comments

@NTillmann
Copy link
Contributor

This crashes Prepack. The issue that binding assignments don't have to happen in optimized functions.

let g = __abstract("function", "(obj)");
global.result = __evaluatePureFunction(() => {
    let x = 23;
    function incrementX() {
        x = x + 42;
    }
    global.__optimize && __optimize(incrementX);
    g(incrementX);
    return x;
});

==>

Invariant Violation:
This is likely a bug in Prepack, not your code. Feel free to open an issue on GitHub.
    at invariant (/Users/nikolait/git/prepack/lib/invariant.js:24:15)
    at Object.visitBindingAssignment (/Users/nikolait/git/prepack/lib/serializer/ResidualHeapVisitor.js:1182:34)
    at BindingAssignmentEntry.visit (/Users/nikolait/git/prepack/lib/utils/generator.js:358:26)
    at visitFn (/Users/nikolait/git/prepack/lib/utils/generator.js:818:46)
    at Generator.visit (/Users/nikolait/git/prepack/lib/utils/generator.js:826:7)
    at _withScope (/Users/nikolait/git/prepack/lib/serializer/ResidualHeapVisitor.js:1200:17)
    at ResidualHeapVisitor._withScope (/Users/nikolait/git/prepack/lib/serializer/ResidualHeapVisitor.js:208:7)
    at ResidualHeapVisitor.visitGenerator (/Users/nikolait/git/prepack/lib/serializer/ResidualHeapVisitor.js:1199:10)
    at ResidualHeapVisitor.visitRoots (/Users/nikolait/git/prepack/lib/serializer/ResidualHeapVisitor.js:1248:10)
    at statistics.deepTraversal.measure (/Users/nikolait/git/prepack/lib/serializer/serializer.js:204:70)
@NTillmann NTillmann added the bug label Aug 3, 2018
@NTillmann NTillmann changed the title Regression due to #2344 Leaking outside of optimized functions not supported Aug 3, 2018
@calebmer calebmer self-assigned this Aug 15, 2018
facebook-github-bot pushed a commit that referenced this issue Aug 16, 2018
Summary:
Fixes #2419 and #2386. I ran into this issue while testing an internal React Native bundle. This invariant assumes that all property bindings emitted in a pure scope are also in an optimized function. This is not true for `__evaluatePureFunction` which the React Compiler wraps around initialization code so that globals outside of the closure are not havoced.
Pull Request resolved: #2420

Differential Revision: D9363247

Pulled By: calebmer

fbshipit-source-id: 4f1634165b6fe15f95b5b7332432fccacc596821
facebook-github-bot pushed a commit that referenced this issue Aug 22, 2018
Summary:
Fixes #2419 #2386 #2439 #2447 #2432 #2437 #2442

* Fix havoced binding not in optimized function
* Allow arrays with widened numeric properties to update index properties
* Fix nested for statement bailout with nested for-in
* Don’t record modified bindings for immutable bindings when havocing

Reviewed By: trueadm, sebmarkbage

Differential Revision: D9456957

fbshipit-source-id: f266b8cc73012b9c721f0f9eebd48347bf0e37ae
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants