public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Naresh Kamboju <naresh.kamboju@linaro.org>, kees@kernel.org
Cc: clang-built-linux <llvm@lists.linux.dev>,
	kunit-dev@googlegroups.com,
	open list <linux-kernel@vger.kernel.org>,
	David Gow <davidgow@google.com>, Arnd Bergmann <arnd@arndb.de>,
	Anders Roxell <anders.roxell@linaro.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	Rae Moar <rmoar@google.com>
Subject: Re: DEFINE_FLEX_test: EXPECTATION FAILED at lib/overflow_kunit.c:1200:
Date: Tue, 19 Nov 2024 08:05:16 -0700	[thread overview]
Message-ID: <20241119150516.GB2196859@thelio-3990X> (raw)
In-Reply-To: <CA+G9fYs0mh8ex1wWYTW_o+BstwCAZ6rgQJZbGRkSH4WoQNTJdw@mail.gmail.com>

Hi Naresh,

+ Kees (it does not look like you own lib/overflow_kunit.c, should that
be updated?)

On Tue, Nov 19, 2024 at 04:17:41PM +0530, Naresh Kamboju wrote:
> The overflow_DEFINE_FLEX_test KUnit test case. This test consistently
> passes when built with GCC-13 but fails when using Clang-19 or
> Clang-nightly.
> 
> Test Case: overflow_DEFINE_FLEX_test
> Compilers: Passing: GCC-13
>            Failing: Clang-19, Clang-nightly
> Observed Behavior: The test failure is reproducible with Clang builds,
>                    while GCC builds produce consistent success.
> 
> This inconsistency suggests a potential issue either in the Clang toolchain
> or in the test implementation that is exposed by Clang's compilation behavior.
> 
> Test log:
> ----------
> <6>[   92.471692]     # castable_to_type_test: 103 castable_to_type()
> tests finished
> <6>[   92.474933]     ok 21 castable_to_type_test
> <3>[   92.476715]     # DEFINE_FLEX_test: EXPECTATION FAILED at
> lib/overflow_kunit.c:1200
> <3>[   92.476715]     Expected
> __builtin_dynamic_object_size(two_but_zero, 0) == expected_raw_size,
> but
> <3>[   92.476715]         __builtin_dynamic_object_size(two_but_zero,
> 0) == 12 (0xc)
> <3>[   92.476715]         expected_raw_size == 8 (0x8)
> <6>[   92.480178]     not ok 22 DEFINE_FLEX_test
> <6>[   92.483020] # overflow: pass:21 fail:1 skip:0 total:22

I can reproduce this with Clang 19.1.3 on 6.12, so it does not appear to
be a recent problem.

  $ printf 'CONFIG_%s=y\n' KUNIT OVERFLOW_KUNIT_TEST >kernel/configs/overflow_kunit.config

  $ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper {def,hardening.,overflow_kunit.}config Image.gz

  $ boot-qemu.py ...
  [    0.000000] Linux version 6.12.0 (nathan@thelio-3990X) (ClangBuiltLinux clang version 19.1.3 (https://github.com/llvm/llvm-project.git ab51eccf88f5321e7c60591c5546b254b6afab99), ClangBuiltLinux LLD 19.1.3 (https://github.com/llvm/llvm-project.git ab51eccf88f5321e7c60591c5546b254b6afab99)) #1 SMP PREEMPT Tue Nov 19 07:28:39 MST 2024
  ...
  [    4.184764]     # DEFINE_FLEX_test: EXPECTATION FAILED at lib/overflow_kunit.c:1200
  [    4.184764]     Expected __builtin_dynamic_object_size(two_but_zero, 0) == expected_raw_size, but
  [    4.184764]         __builtin_dynamic_object_size(two_but_zero, 0) == 12 (0xc)
  [    4.184764]         expected_raw_size == 8 (0x8)
  [    4.190023]     not ok 22 DEFINE_FLEX_test
  [    4.206181] # overflow: pass:21 fail:1 skip:0 total:22
  [    4.208635] # Totals: pass:21 fail:1 skip:0 total:22
  [    4.212218] not ok 1 overflow
  ...

I do not really understand how __builtin_dynamic_object_size() can
return 12 for two_but_zero with __counted_by() because DEFINE_RAW_FLEX()
does not initialize the counter so it should be zero... Kees? I guess
maybe something changed on the LLVM side, I will see if I can bisect
later (all the boxes are tied up with other compilations at the moment).

Cheers,
Nathan

  reply	other threads:[~2024-11-19 15:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 10:47 DEFINE_FLEX_test: EXPECTATION FAILED at lib/overflow_kunit.c:1200: Naresh Kamboju
2024-11-19 15:05 ` Nathan Chancellor [this message]
2024-11-19 17:38   ` Kees Cook
2024-11-20  6:28     ` David Gow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241119150516.GB2196859@thelio-3990X \
    --to=nathan@kernel.org \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@arndb.de \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=kees@kernel.org \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=naresh.kamboju@linaro.org \
    --cc=ndesaulniers@google.com \
    --cc=rmoar@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox