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

Lazy matchStrings regex can cause out of memory crash #22083

Closed
rarkins opened this issue May 11, 2023 · 5 comments · Fixed by #22084
Closed

Lazy matchStrings regex can cause out of memory crash #22083

rarkins opened this issue May 11, 2023 · 5 comments · Fixed by #22084
Assignees
Labels
priority-2-high Bugs impacting wide number of users or very important features status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality

Comments

@rarkins
Copy link
Collaborator

rarkins commented May 11, 2023

How are you running Renovate?

Self-hosted Renovate

If you're self-hosting Renovate, tell us what version of Renovate you run.

source

If you're self-hosting Renovate, select which platform you are using.

github.com

Was this something which used to work for you, and then stopped?

I am trying to get this working for the first time

Describe the bug

This causes the problem: https://github.com/rarkins/sha_renovate/blob/505a1639c36daa398e09937f72432939d2740e0d/renovate.json#L9

Replacing it with "^(?<currentDigest>.*?)(\n|$)" works

Relevant debug logs

Logs
DEBUG: Matched 1 file(s) for manager regex: .sha.txt (repository=rarkins/sha_renovate)

<--- Last few GCs --->

[9672:0x128078000]    46270 ms: Mark-sweep 4037.6 (4130.8) -> 4034.0 (4129.8) MB, 2649.0 / 0.0 ms  (average mu = 0.318, current mu = 0.117) allocation failure; scavenge might not succeed
[9672:0x128078000]    51007 ms: Mark-sweep 4049.8 (4129.8) -> 4045.5 (4154.8) MB, 4674.1 / 0.0 ms  (average mu = 0.145, current mu = 0.013) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Have you created a minimal reproduction repository?

I have linked to a minimal reproduction in the description above

@rarkins rarkins added type:bug Bug fix of existing functionality priority-2-high Bugs impacting wide number of users or very important features status:ready labels May 11, 2023
@viceice
Copy link
Member

viceice commented May 11, 2023

I saw it. maybe an RE2 bug?

@rarkins
Copy link
Collaborator Author

rarkins commented May 11, 2023

This reproduces in the regex manager dir:

import { regEx } from '../../../util/regex';
import * as utils from './utils';

describe('modules/manager/regex/utils', () => {
  it('crashes', () => {
    const lazyMatch = regEx('(?<currentDigest>.*?)', 'g');
    expect(
      utils.regexMatchAll(
        lazyMatch,
        '1f699d2bfc99bbbe4c1ed5bb8fc21e6911d69c6e\n'
      )
    ).toMatchInlineSnapshot();
  });
})

Notice how it's a global match and we match all

@rarkins
Copy link
Collaborator Author

rarkins commented May 11, 2023

Fix: #22084

@viceice
Copy link
Member

viceice commented May 11, 2023

It's a RE2 issue

const r = require('re2');
// works: 41 same matches
[...'1f699d2bfc99bbbe4c1ed5bb8fc21e6911d69c6e\n'.matchAll(/(?<currentDigest>.*?)/g)]
// craches with oom
[...'1f699d2bfc99bbbe4c1ed5bb8fc21e6911d69c6e\n'.matchAll(new r(/(?<currentDigest>.*?)/g))]

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 35.79.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority-2-high Bugs impacting wide number of users or very important features status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants