Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -Wuninitialized #381

Closed
nathanchance opened this issue Feb 26, 2019 · 14 comments
Closed

Enable -Wuninitialized #381

nathanchance opened this issue Feb 26, 2019 · 14 comments
Assignees
Labels
-Wsometimes-uninitialized -Wuninitialized [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.3 This bug was fixed in Linux 5.3

Comments

@nathanchance
Copy link
Member

29b00e6 would have been caught with Clang in its default configuration (and not by GCC due to a bug), as pointed out in this thread: https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

However, -Wuninitialized also disables -Wsometimes-uninitialized so this was missed by both compilers :(

I am going to test the following diff then send it along right away if there are no additional warnings:

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 768306add591..f4332981ea85 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -72,5 +72,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format)
 KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
 KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
+KBUILD_CFLAGS += $(call cc-option, -Wsometimes-uninitialized)
 endif
 endif

Side note, looks like this might be a good time to tell Linus about the KernelCI work that is going on: https://lore.kernel.org/lkml/CAHk-=wggjLsi-1BmDHqWAJPzBvTD_-MQNo5qQ9WCuncnyWPROg@mail.gmail.com/

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. [PATCH] Exists There is a patch that fixes this issue labels Feb 26, 2019
@nathanchance nathanchance self-assigned this Feb 26, 2019
@nickdesaulniers
Copy link
Member

heh, wish I was cc'ed on that thread (I'm not subbed to lkml, ducks)

@nathanchance
Copy link
Member Author

I'm not subbed to lkml, ducks

Neither am I, I happened to stumble across it while browsing https://lore.kernel.org/lkml/. Guess I should be after this.

It is still possible to reply without being CC'd (if you use mutt). Otherwise, the link gives reply instructions using git send-email at the bottom.

$ curl -LSs -o mbox https://lore.kernel.org/lkml/CAHk-=wggjLsi-1BmDHqWAJPzBvTD_-MQNo5qQ9WCuncnyWPROg@mail.gmail.com/raw
$ mutt -f mbox

@nathanchance nathanchance changed the title -Wno-uninitialized also disabled -Wsometimes-uninitialized Enable -Wsometimes-uninitialized Feb 26, 2019
@nathanchance
Copy link
Member Author

Unfortunately, introduces a few warnings: https://gist.github.com/nathanchance/59f35754366c7d68141a5f44fe9302b8

Another project like #378 (seems like it could be achieved quicker).

@nickdesaulniers
Copy link
Member

Yes; and many of those have the same source file (and even the same warning in some cases; like maybe a shared problematic macro). Thanks for the link; I'll file bugs for all of those, and we'll use this to track enabling the warning.

@nickdesaulniers
Copy link
Member

12 altogether (including this one)

@nathanchance nathanchance added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Jun 24, 2019
masahir0y pushed a commit to masahir0y/linux that referenced this issue Jul 7, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
masahir0y pushed a commit to masahir0y/linux that referenced this issue Jul 8, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
masahir0y pushed a commit to masahir0y/linux that referenced this issue Jul 9, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
masahir0y pushed a commit to masahir0y/linux that referenced this issue Jul 9, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
masahir0y pushed a commit to masahir0y/linux that referenced this issue Jul 12, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
@nathanchance
Copy link
Member Author

Merged into mainline: https://git.kernel.org/torvalds/c/3a61925e91ba9f0ece1b444eb1aa49caa59e4ae7

@nathanchance nathanchance added [FIXED][LINUX] 5.3 This bug was fixed in Linux 5.3 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Jul 12, 2019
Eamo5 pushed a commit to Eamo5/linux that referenced this issue Jul 21, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Eamo5 pushed a commit to Eamo5/linux that referenced this issue Jul 22, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Eamon Powell <eamonpowell@outlook.com>
0ranko0P pushed a commit to 0ranko0P/kernel_xiaomi_msm8998 that referenced this issue Oct 27, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
0ranko0P pushed a commit to 0ranko0P/kernel_xiaomi_msm8998 that referenced this issue Oct 28, 2019
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Dec 24, 2019
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Dec 25, 2019
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jan 7, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jan 28, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
RealAkito pushed a commit to HarukaNetwork/haruka-workstation-kernel that referenced this issue Mar 23, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
Signed-off-by: Akito Mizukito <akito@evolution-x.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Apr 2, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
nathanchance pushed a commit that referenced this issue Jun 11, 2020
Add and use snd_pcm_stream_lock_nested() in snd_pcm_link/unlink
implementation.  The code is fine, but generates a lockdep complaint:

============================================
WARNING: possible recursive locking detected
5.7.1mq+ #381 Tainted: G           O
--------------------------------------------
pulseaudio/4180 is trying to acquire lock:
ffff888402d6f508 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xda8/0xee0 [snd_pcm]

but task is already holding lock:
ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&group->lock);
  lock(&group->lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by pulseaudio/4180:
 #0: ffffffffa1a05190 (snd_pcm_link_rwsem){++++}-{3:3}, at: snd_pcm_common_ioctl+0xca0/0xee0 [snd_pcm]
 #1: ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]
[...]

Cc: stable@vger.kernel.org
Fixes: f57f3df ("ALSA: pcm: More fine-grained PCM link locking")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/37252c65941e58473b1219ca9fab03d48f47e3e3.1591610330.git.mirq-linux@rere.qmqm.pl

Signed-off-by: Takashi Iwai <tiwai@suse.de>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jun 19, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jun 22, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 23, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 24, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 24, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 24, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 24, 2020
This will be turned on for the whole kernel, as we want to catch these
cases.

This reverts commit c562746.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
0ranko0P pushed a commit to 0ranko0P/kernel_xiaomi_msm8998 that referenced this issue Nov 2, 2020
This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: ClangBuiltLinux/linux#381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: 0ranko0P <ranko0p@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wsometimes-uninitialized -Wuninitialized [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.3 This bug was fixed in Linux 5.3
Projects
None yet
Development

No branches or pull requests

2 participants