Bug 203437
Summary: | scripts/kconfig/nconf.c stuck in infinite loop in search | ||
---|---|---|---|
Product: | Tools | Reporter: | GYt2bW (howaboutsynergy) |
Component: | Other | Assignee: | Tools.Other (tools_other) |
Status: | CLOSED CODE_FIX | ||
Severity: | normal | CC: | adjudicatordarren, howaboutsynergy, rdunlap |
Priority: | P1 | ||
Hardware: | x86-64 | ||
OS: | Linux | ||
Kernel Version: | v5.1-rc6 | Subsystem: | |
Regression: | No | Bisected commit-id: | |
Attachments: | naive workaround |
Hi, Please report this problem and your solution to linux-kbuild@vger.kernel.org . I would expect the kbuild/kconfig maintainer to reply to it there. Thanks. (In reply to Randy Dunlap from comment #1) yeah, I was afraid it wasn't that simple :) now I'm being asked to do things from this: https://github.com/torvalds/linux/blob/master/Documentation/process/submitting-patches.rst and let me just say it's never gonna happen. besides, it is a `naive workaround`, I expect actual devs to fix it properly :D The kbuild/kconfig maintainer is just asking for an email with the problem description and patch. It's pretty easy to do that. Although the patch would need a Signed-off-by: line with your real name and email address in it. We mostly work through email, not bugzilla. Anyway, thanks for the report and analysis. finally got fixed in stable by https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/scripts/kconfig/nconf.c?h=linux-5.12.y&id=3c96f542bf751c3e6c16c28b57d737aedbcc106e or in git upstream commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8c94b430b9f6213dec84e309bb480a71778c4213 thanks bros :) tested fixed |
Created attachment 282549 [details] naive workaround Repro. steps: 1. $ make nconfig 2. Go to `File Systems` 3. Press `/` to search and type `cp` 4. Press and release DownArrow key, then UpArrow key The `nconf` process is now stuck in an infinite loop using 100% CPU (one full core) 5. press C-c to stop This happens because `match_start` is `-1` and thus, since `index` will not reach values less than `0` (apparently), it won't ever exit the `while (true)` loop. naive workaround(also attached): ```diff diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index ac92c0ded6c5..9f1d85acc572 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -505,7 +505,7 @@ static int get_mext_match(const char *match_str, match_f flag) index = match_start; index = (index + items_num) % items_num; - while (true) { + while (match_start != -1) { char *str = k_menu_items[index].str; if (strcasestr(str, match_str) != NULL) return index; @@ -516,8 +516,9 @@ static int get_mext_match(const char *match_str, match_f flag) ++index; index = (index + items_num) % items_num; if (index == match_start) - return -1; + break; } + return -1; } /* Make a new item. */ ```