linux-next/scripts/kconfig/tests
HONG Yifan 9d0d266046 kconfig: recursive checks drop file/lineno
This prevents segfault when getting filename and lineno in recursive
checks.

If the following snippet is found in Kconfig:

[Test code 1]

config FOO
        bool
        depends on BAR
        select BAR

... without BAR defined; then there is a segfault.

  Kconfig:34:error: recursive dependency detected!
  Kconfig:34:	symbol FOO depends on BAR
  make[4]: *** [scripts/kconfig/Makefile:85: allnoconfig] Segmentation fault

This is because of the following. BAR is a fake entry created by
sym_lookup() with prop being NULL. In the recursive check, there is a
NULL check for prop to fall back to stack->sym->prop if stack->prop is
NULL. However, in this case, stack->sym points to the fake BAR entry
created by sym_lookup(), so prop is still NULL. prop was then referenced
without additional NULL checks, causing segfault.

As the previous email thread suggests, the file and lineno for select is
also wrong:

[Test code 2]

config FOO
       bool

config BAR
       bool

config FOO
       bool "FOO"
       depends on BAR
       select BAR

  $ make defconfig
  *** Default configuration is based on 'x86_64_defconfig'
  Kconfig:1:error: recursive dependency detected!
  Kconfig:1: symbol FOO depends on BAR
  Kconfig:4: symbol BAR is selected by FOO
  [...]

Kconfig:4 should be Kconfig:10.

This patch deletes the wrong and segfault-prone filename/lineno
inference completely. With this patch, Test code 1 yields:

error: recursive dependency detected!
	symbol FOO depends on BAR
	symbol BAR is selected by FOO

Signed-off-by: HONG Yifan <elsk@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-07-20 16:33:45 +09:00
..
auto_submenu kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
choice kconfig: remove tristate choice support 2024-07-16 01:08:36 +09:00
choice_randomize kconfig: tests: add a test for randconfig with dependent choices 2024-03-21 02:39:55 +09:00
choice_randomize2 kconfig: tests: test dependency after shuffling choices 2024-03-21 02:40:39 +09:00
err_recursive_dep kconfig: recursive checks drop file/lineno 2024-07-20 16:33:45 +09:00
err_recursive_inc kconfig: tests: fix recursive inclusion unit test 2019-06-05 02:33:10 +09:00
new_choice_with_dep kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
no_write_if_dep_unmet kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
preprocess kconfig: test: add Kconfig macro language tests 2018-05-29 03:31:19 +09:00
conftest.py kconfig: tests: support KCONFIG_SEED for the randconfig runner 2024-03-21 02:39:40 +09:00
pytest.ini kconfig: tests: add framework for Kconfig unit testing 2018-03-26 02:04:01 +09:00