Skip to content

combinations suffers a performance issue under some arguments #16

@zyscoder

Description

@zyscoder

Version

node v22.11.0
npm 10.9.0

Platform

Linux u24vm 6.8.0-48-generic #48-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 14:04:52 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

What steps will reproduce the bug?

  1. Try to install the package: combinations
a. npm init -y
b. npm shrinkwrap
c. npm install --save combinations
d. npm audit fix

the final package.json is as follows:

{
  "name": "package-9256e4c379ff4a504a88c567d54dcb97",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "combinations": "^1.0.0"
  }
}
  1. Setup a node instance,
node
  1. and run the following javascript code.
(async function() {
    var lib = await import('combinations');
    var result = lib.default(["a"], -2504920488, 2**64);;
    console.log(result);
})();

Then the node instance will hang and no response returned.

How often does it reproduce? Is there a required condition?

This issue can always be triggered following the steps above.

What is the expected behavior? Why is that the expected behavior?

No matter how to set the min and max parameters, the result will always be a subset of [ [ 'a' ] ]. It's not reasonable to stuck so much time here.

What do you see instead?

» node
Welcome to Node.js v22.11.0.
Type ".help" for more information.

(async function() {
... var lib = await import('combinations');
... var result = lib.default(["a"], -2504920488, 2**64);;
... console.log(result);
... })();
Promise {
,
[Symbol(async_id_symbol)]: 29,
[Symbol(trigger_async_id_symbol)]: 6
}
(the node server hanged here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions