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

Unfrozen object leaked with webpack plugin after 0.2.6 #1313

Closed
GeKorm opened this issue Jan 4, 2018 · 6 comments
Closed

Unfrozen object leaked with webpack plugin after 0.2.6 #1313

GeKorm opened this issue Jan 4, 2018 · 6 comments
Assignees
Labels

Comments

@GeKorm
Copy link

GeKorm commented Jan 4, 2018

Hello! Using gajus/prepack-webpack-plugin with React, prepack versions after 0.2.6 produce the following error:

PP0017: Unfrozen object leaked before end of global code at [...]

We tried various simple setups but we're always getting this error.
Relevant plugin issue gajus/prepack-webpack-plugin#32

@hermanventer
Copy link
Contributor

See https://github.com/facebook/prepack/wiki/PP0017 for why this is a problem that cannot be safely ignored (as it was up until 0.2.6).

If this is an area where Prepack needs to improve in order to be useful, it will be very helpful if you can provide a test case.

@axules
Copy link

axules commented Jan 25, 2018

prepack v.0.2.20
Error was generated in \node_modules\prepack\lib\utils\leak.js:513

function ensureFrozenValue(realm, value, loc) {
  // TODO: This should really check if it is recursively immutability.
  if (value instanceof _index.ObjectValue && !(0, _index2.TestIntegrityLevel)(realm, value, "frozen")) {
    var diag = new _errors.CompilerDiagnostic("Unfrozen object leaked before end of global code", loc || realm.currentLocation, "PP0017", "RecoverableError");
    if (realm.handleError(diag) !== "Recover") throw new _errors.FatalError();
  }
}

Because TestIntegrityLevel (\node_modules\prepack\lib\methods\integrity.js:147) returned false in 4

// 3. Let status be ? IsExtensible(O).
  var status = (0, _index2.IsExtensible)(realm, O);

  // 4. If status is true, return false.
  if (status === true) return false;

Next IsExtensible(realm, O) in \node_modules\prepack\lib\methods\is.js:116
Next $IsExtensible in \node_modules\prepack\lib\values\ObjectValue.js:452
Next OrdinaryIsExtensible in \node_modules\prepack\lib\methods\is.js:110
And in the end getExtensible in \node_modules\prepack\lib\values\ObjectValue.js:256

Function getExtensible was executed 1315 times on build and only once returned not true value.

I think, TestIntegrityLevel (\node_modules\prepack\lib\methods\integrity.js:147) should be reviewed and tested.

@axules
Copy link

axules commented Jan 27, 2018

Stack trace

Error: PP0017: Unfrozen object leaked before end of global code at 2:1 to 72834:8
Error
    at main.ca62a6d893b65b967b8d.js:2:2
D:\projects\just_project\node_modules\prepack\lib\environment.js:1224
          throw err;
          ^

Error: A fatal error occurred while prepacking.
    at new FatalError (D:\projects\just_project\node_modules\prepack\lib\errors.js:48:14)
    at ensureFrozenValue (D:\projects\just_project\node_modules\prepack\lib\utils\leak.js:513:54)
    at LeakImplementation.leakValue (D:\projects\just_project\node_modules\prepack\lib\utils\leak.js:533:9)
    at generateRuntimeCall (D:\projects\just_project\node_modules\prepack\lib\evaluators\CallExpression.js:134:28)
    at EvaluateCall (D:\projects\just_project\node_modules\prepack\lib\evaluators\CallExpression.js:188:12)
    at exports.default (D:\projects\just_project\node_modules\prepack\lib\evaluators\CallExpression.js:30:10)
    at LexicalEnvironment.evaluateAbstract (D:\projects\just_project\node_modules\prepack\lib\environment.js:1539:22)
    at LexicalEnvironment.evaluate (D:\projects\just_project\node_modules\prepack\lib\environment.js:1527:22)
    at exports.default (D:\projects\just_project\node_modules\prepack\lib\evaluators\ExpressionStatement.js:10:21)
    at LexicalEnvironment.evaluateAbstract (D:\projects\just_project\node_modules\prepack\lib\environment.js:1539:22)
    at LexicalEnvironment.evaluate (D:\projects\just_project\node_modules\prepack\lib\environment.js:1527:22)
    at LexicalEnvironment.evaluateCompletion (D:\projects\just_project\node_modules\prepack\lib\environment.js:1215:21)
    at LexicalEnvironment.evaluateCompletionDeref (D:\projects\just_project\node_modules\prepack\lib\environment.js:1207:25)
    at exports.default (D:\projects\just_project\node_modules\prepack\lib\evaluators\Program.js:34:23)
    at LexicalEnvironment.evaluateAbstract (D:\projects\just_project\node_modules\prepack\lib\environment.js:1539:22)
    at LexicalEnvironment.evaluate (D:\projects\just_project\node_modules\prepack\lib\environment.js:1527:22)
    at exports.default (D:\projects\just_project\node_modules\prepack\lib\evaluators\File.js:8:15)
    at LexicalEnvironment.evaluateAbstract (D:\projects\just_project\node_modules\prepack\lib\environment.js:1539:22)
    at LexicalEnvironment.evaluate (D:\projects\just_project\node_modules\prepack\lib\environment.js:1527:22)
    at LexicalEnvironment.evaluateCompletion (D:\projects\just_project\node_modules\prepack\lib\environment.js:1215:21)
    at LexicalEnvironment.executeSources (D:\projects\just_project\node_modules\prepack\lib\environment.js:1327:20)
    at Serializer._execute (D:\projects\just_project\node_modules\prepack\lib\serializer\serializer.js:101:52)
    at Serializer.init (D:\projects\just_project\node_modules\prepack\lib\serializer\serializer.js:141:23)
    at prepack (D:\projects\just_project\node_modules\prepack\lib\prepack-standalone.js:154:31)
    at Compilation.compilation.plugin (D:\projects\just_project\node_modules\prepack-webpack-plugin\dist\PrepackPlugin.js:58:56)
    at Compilation.applyPluginsAsyncSeries (D:\projects\just_project\node_modules\tapable\lib\Tapable.js:206:13)
    at self.applyPluginsAsync.err (D:\projects\just_project\node_modules\webpack\lib\Compilation.js:666:10)
    at next (D:\projects\just_project\node_modules\tapable\lib\Tapable.js:202:11)
    at Compilation.<anonymous> (D:\projects\just_project\node_modules\purifycss-webpack\dist\index.js:102:11)
    at next (D:\projects\just_project\node_modules\tapable\lib\Tapable.js:204:14)

@axules
Copy link

axules commented Feb 12, 2018

Hack - for prepack v0.2.7 and next

  1. Open \node_modules\prepack\lib\utils\leak.js
  2. Find function ensureFrozenValue
  3. Update this function - add false into if
function ensureFrozenValue(realm, value, loc) {
  // TODO: This should really check if it is recursively immutability.
  if (false && value instanceof _index.ObjectValue && !(0, _index2.TestIntegrityLevel)(realm, value, "frozen")) {
...

@NTillmann
Copy link
Contributor

From the stack trace I see that this is being triggered by some call to an effectively abstract function (generateRuntimeCall). Maybe that function is actually known to not mutate any state (see discussion here: #705).

Can you give me instructions on how to repro the issue?

@NTillmann
Copy link
Contributor

Closing due to lack of repro.

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

No branches or pull requests

5 participants