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

v2.4.1 crashes due to a memory leak/exclude is broken #847

Closed
birdofpreyru opened this issue Oct 6, 2021 · 15 comments · Fixed by #851
Closed

v2.4.1 crashes due to a memory leak/exclude is broken #847

birdofpreyru opened this issue Oct 6, 2021 · 15 comments · Fixed by #851

Comments

@birdofpreyru
Copy link

Bug report

My existing projet works fine with mini-css-extract-plugin@2.3.0. After upgrading to the latest v2.4.1 my project builds fail, seemingly due to some memory leak:

<--- Last few GCs --->

[146088:0x4e466f0]    18721 ms: Mark-sweep (reduce) 2045.8 (2051.7) -> 2045.5 (2054.7) MB, 652.9 / 0.0 ms  (average mu = 0.264, current mu = 0.019) allocation failure scavenge might not succeed
[146088:0x4e466f0]    19389 ms: Mark-sweep (reduce) 2046.5 (2055.2) -> 2046.3 (2055.7) MB, 665.6 / 0.0 ms  (average mu = 0.147, current mu = 0.004) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
 1: 0xa389b0 node::Abort() [node]
 2: 0x96e0af node::FatalError(char const*, char const*) [node]
 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd73fd5  [node]
 6: 0xda496e v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [node]
 7: 0xdb09a6 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [node]
 8: 0xd9cb3f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [node]
 9: 0xd9cdb8 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [node]
10: 0xd8f699 v8::internal::ItemParallelJob::Run() [node]
...

Taking into account v2.4.1 release comments saying bug fix: crash with multiple webpack versions, my first guess, there are still some problems left. I am on the latest webpack@5.57.1, by the way.

Actual Behavior

Presumably v2.4.0 introduces some memory leak, causing crashes at least in some edge-cases.

Expected Behavior

Upgrade from v2.3.0 to v.2.4.1 should not lead to crashes in the projects where build worked with the previous versions.

How Do We Reproduce?

I had no chance to dig into it. I'll provide a way to reproduce later, if you don't have an idea already what might be wrong with it.

Please paste the results of npx webpack-cli info here, and mention other relevant information

npx: installed 50 in 7.909s

  System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 2.16 GB / 11.60 GB
  Binaries:
    Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.0/bin/npm
  Browsers:
    Chrome: 94.0.4606.71
    Firefox: 92.0
  Packages:
    babel-loader: ^8.2.2 => 8.2.2 
    css-loader: ^6.3.0 => 6.3.0 
    css-minimizer-webpack-plugin: ^3.1.1 => 3.1.1 
    postcss-loader: ^6.1.1 => 6.1.1 
    resolve-url-loader: ^4.0.0 => 4.0.0 
    sass-loader: ^12.1.0 => 12.1.0 
    webpack: ^5.57.1 => 5.57.1 
    webpack-dev-middleware: ^5.2.1 => 5.2.1 
    webpack-hot-middleware: ^2.25.1 => 2.25.1 
    webpack-merge: ^5.8.0 => 5.8.0 
    workbox-webpack-plugin: ^6.3.0 => 6.3.0
@alexander-akait
Copy link
Member

alexander-akait commented Oct 6, 2021

How Do We Reproduce?
I had no chance to dig into it. I'll provide a way to reproduce later, if you don't have an idea already what might be wrong with it.

Sorry, can't help due this, as minimum we need profile, can you provide some more info?

@birdofpreyru
Copy link
Author

birdofpreyru commented Oct 6, 2021

@alexander-akait well, if you don't mind to look into non-minimal example, clone this: https://github.com/birdofpreyru/react-utils, and see the latest commit in master branch (4659b7968cf307e6a6a4cedb166e0e9fd626525b).

That commit still has v2.3.0. If you do npm install then both npm run build and then npm test will work.

If you upgrade npm install --save mini-css-extract-plugin@latest then both npm run build and then npm test fail for me with that memory corruption message.

@alexander-akait
Copy link
Member

@birdofpreyru Big thanks, I will look at this in near future, we migrate on new API, so I think something wrong on webpack side, you should speed up and decrease memory usage after this update

@huineng
Copy link

huineng commented Oct 7, 2021

yes, 2.4.1 still leads to memory crash, more or less the same log as above (webpack@5.57.1 / node v16.10.0)

41% building 1/2 entries 11125/11125 dependencies 2905/3900 modules
<--- Last few GCs --->

[42343:0x7fe8d8008000]   279500 ms: Scavenge (reduce) 4022.1 (4106.0) -> 4021.8 (4106.2) MB, 4.1 / 0.0 ms  (average mu = 0.377, current mu = 0.372) allocation failure 
[42343:0x7fe8d8008000]   279571 ms: Scavenge (reduce) 4022.4 (4106.2) -> 4022.1 (4106.7) MB, 4.3 / 0.0 ms  (average mu = 0.377, current mu = 0.372) allocation failure 
[42343:0x7fe8d8008000]   279633 ms: Scavenge (reduce) 4022.7 (4106.7) -> 4022.4 (4106.7) MB, 3.7 / 0.0 ms  (average mu = 0.377, current mu = 0.372) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10a87d165 node::Abort() [/usr/local/bin/node]
 2: 0x10a87d2e8 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x10a9f3387 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x10a9f3323 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x10abad1b5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 6: 0x10abb112b v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 7: 0x10abadaa3 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10abab0ce v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x10aba9fe8 v8::internal::Heap::HandleGCRequest() [/usr/local/bin/node]
10: 0x10ab545d1 v8::internal::StackGuard::HandleInterrupts() [/usr/local/bin/node]
11: 0x10af125b0 v8::internal::NativeRegExpMacroAssembler::CheckStackGuardState(v8::internal::Isolate*, int, v8::internal::RegExp::CallOrigin, unsigned long*, v8::internal::Code, unsigned long*, unsigned char const**, unsigned char const**) [/usr/local/bin/node]
12: 0x10b1cdb5b v8::internal::RegExpMacroAssemblerX64::CheckStackGuardState(unsigned long*, unsigned long, unsigned long) [/usr/local/bin/node]
13: 0x10f56feb0 
14: 0x10af12833 v8::internal::NativeRegExpMacroAssembler::Execute(v8::internal::String, int, unsigned char const*, unsigned char const*, int*, int, v8::internal::Isolate*, v8::internal::JSRegExp) [/usr/local/bin/node]
15: 0x10af1277a v8::internal::NativeRegExpMacroAssembler::Match(v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int*, int, int, v8::internal::Isolate*) [/usr/local/bin/node]
16: 0x10af1eb1d v8::internal::RegExpImpl::IrregexpExecRaw(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, int*, int) [/usr/local/bin/node]
17: 0x10af1d75f v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) [/usr/local/bin/node]
18: 0x10af3d9d7 v8::internal::Runtime_RegExpExecTreatMatchAtEndAsFailure(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
19: 0x10b2c2739 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
20: 0x10b319b84 Builtins_RegExpSplit [/usr/local/bin/node]

@pavelthq
Copy link

pavelthq commented Oct 7, 2021

same for me, easy replicateable in: https://github.com/pavelthq/mini-css-issue-241

run:

yarn install
yarn test

in 2.0.0 it works fine.
in 2.4.1 hangs:

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa389b0 node::Abort() [webpack]
 2: 0x96e0af node::FatalError(char const*, char const*) [webpack]
 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [webpack]
 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [webpack]
 5: 0xd73fd5  [webpack]
 6: 0xd74b5f  [webpack]
 7: 0xd8299b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [webpack]
 8: 0xd8655c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [webpack]
 9: 0xd4f6be v8::internal::Factory::NewMap(v8::internal::InstanceType, int, v8::internal::ElementsKind, int) [webpack]
10: 0xf5b90b v8::internal::Map::RawCopy(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, int, int) [webpack]
11: 0xf5c05b v8::internal::Map::CopyDropDescriptors(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>) [webpack]
12: 0xf5c85d  [webpack]
13: 0xf5d5f2 v8::internal::Map::Copy(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, char const*) [webpack]
14: 0xf37507 v8::Maybe<bool> v8::internal::JSObject::PreventExtensionsWithTransition<(v8::internal::PropertyAttributes)0>(v8::internal::Handle<v8::internal::JSObject>, v8::internal::ShouldThrow) [webpack]
15: 0xf3763f v8::internal::JSObject::PreventExtensions(v8::internal::Handle<v8::internal::JSObject>, v8::internal::ShouldThrow) [webpack]
16: 0x10b350a v8::internal::Runtime_JSReceiverPreventExtensionsThrow(int, unsigned long*, v8::internal::Isolate*) [webpack]

@alexander-akait
Copy link
Member

@pavelthq 404, maybe private?

@pavelthq
Copy link

pavelthq commented Oct 7, 2021

@alexander-akait tried in incognito works fine, it is public. https://github.com/pavelthq/mini-css-issue-241

@alexander-akait
Copy link
Member

@pavelthq Note, please migrate from optimize-css-assets-webpack-plugin on https://github.com/webpack-contrib/css-minimizer-webpack-plugin, investigating your problem

@alexander-akait
Copy link
Member

alexander-akait commented Oct 7, 2021

Found a problem, new API used .webpack special extensions to use importModule (new fast and low memory API), but you use exclude: [/styles\.css/, /editor\.css/], so you apply loader infinity time, workaround exclude: [/styles\.css/, /editor\.css/, /\.webpack/],, I think other developers has the same problem, but yes we should fix it, bug

@alexander-akait alexander-akait changed the title v2.4.1 crashes due to a memory leak v2.4.1 crashes due to a memory leak/exclude is broken Oct 7, 2021
@birdofpreyru
Copy link
Author

Thanks for the quick turn-around @alexander-akait , the workaround solves the problem for me!

@alexander-akait
Copy link
Member

alexander-akait commented Oct 7, 2021

WIP on fix, note for me - we need add testcase for #846

@alexander-akait
Copy link
Member

please try https://github.com/webpack-contrib/mini-css-extract-plugin/releases/tag/v2.4.2, partially fixed, some edge cases still here, we need fix it on webpack side, but should be fine for 99.99%

@pavelthq
Copy link

pavelthq commented Oct 8, 2021

@alexander-akait 2.4.2 works fine on my side, thanks.

@huineng
Copy link

huineng commented Oct 8, 2021

for me also , thanks

@alexander-akait alexander-akait mentioned this issue Oct 9, 2021
6 tasks
@alexander-akait
Copy link
Member

Fixed, if somebody faced with the same issue, please update mini-css-extract-plugin to v2.4.2 and webpack to v5.58.1

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

Successfully merging a pull request may close this issue.

4 participants