unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
6.12k stars 175 forks source link

100% CPU on Linux, possibly stuck in an endless loop #207

Open georgzoeller opened 1 year ago

georgzoeller commented 1 year ago

Environment

Debian Bullseye / Node 20

Reproduction

Something is happening here (potentially related to emojiregexp, not sure) that's causing 100% on linux, it looks like the function may be stuck in an endless loop.

image

If I SIGUSR the process and inspect, I see it is running a loop around here that doesn't seem to end

image

Describe the bug

Specific conditions (have not been able to assertain exactly what the input string is is causing consola 3.2.2 to consume 100% CPU and make the main thread unresponsive. Stracktrace included in repro

Additional context

No response

Logs

No response

image

georgzoeller commented 1 year ago

Bit more info. I don't know the exact string that blew it up, but the input was coming from a CLIP interrogator, which usually contains strings with weights such as

(artist:0.5), (modern:-1), etc. The brackets should be balanced but may not always be

It looks to me like a regexp is misfiring causing an endless loop in consola

kikuchan commented 1 month ago

Probably it's related to #246 (because the backtrace shows stringWidth), and now it's resolved I think.