April 25th, 2025

Some __nonstring__ Turbulence

The release of the 6.15-rc3 kernel faced issues from new GCC 15 warnings, leading to last-minute changes by Linus Torvalds that broke compatibility, prompting discussions on kernel development practices and testing.

Read original articleLink Icon
Some __nonstring__ Turbulence

The recent release of the 6.15-rc3 kernel has highlighted issues arising from the introduction of new compiler warnings in GCC 15, particularly the -Wunterminated-string-initialization warning. This warning aims to help developers identify potential bugs related to string initialization in C, but it has also caused disruptions in the development process. Linus Torvalds updated his development environment to Fedora 42, which includes a pre-release version of GCC 15, just before tagging the kernel release. This led to build failures due to unaddressed warnings, prompting Torvalds to implement last-minute changes to the kernel. However, these changes inadvertently broke compatibility with earlier GCC versions, causing frustration among developers. Kees Cook, who has been working on addressing the new warnings, expressed dissatisfaction with the lack of coordination and the rushed nature of the changes. The situation has sparked a debate about the development process within the kernel community, particularly regarding the need for better testing and review practices. Torvalds and Cook have differing views on how to handle the __nonstring__ attribute, which is intended to indicate that certain char arrays do not require a trailing NUL byte. The ongoing discussions reflect broader concerns about the kernel's development practices and the impact of compiler updates on the community.

- The introduction of new compiler warnings in GCC 15 has caused disruptions in kernel development.

- Linus Torvalds made last-minute changes to the kernel to address build failures, which broke compatibility with earlier GCC versions.

- Kees Cook criticized the lack of coordination and rushed changes, highlighting the need for better testing practices.

- The situation has sparked discussions about the kernel's development process and the handling of compiler updates.

- There are differing opinions on the implementation of the __nonstring__ attribute within the kernel community.

Link Icon 8 comments
By @AceJohnny2 - about 7 hours
Fedora stupidly uses beta compiler in new release, Torvalds blindly upgrades, makes breaking, unreviewed changes in kernel, then flames the maintainer who was working on cleanly updating the kernel for the not-yet-released compiler?

I admire Kees Cook's patience.

By @Ukv - about 5 hours
From the comments:

> C "strings" work the way they do because C is a low level language, where you want to be able to do low-level things when necessary. It's a feature, not a deficiency.

Are NUL-terminated strings really considered preferable, even for low-level work? I always just considered them an unfortunate design choice C was stuck with.

Many O(1) operations/checks become O(n) because you have to linearly traverse the entire string (or keep a second pointer) to know where it ends/how long it is; you can't take a substring within another string without reallocating and copying that part over with a new NUL appended at the end; you can't store data that may contain a NUL (which text shouldn't, in theory, but then you need a separate approach for binary data); and plenty of security issues arise from missing or extra NULs.

By @jaapz - about 6 hours
Torvalds is known for being flamey towards kernel maintainers, but most of the time that is for good reason. Here however, he should just admit he made a mistake instead of doubling down. Admitting your own mistakes is a mark of a great maintainer as well.
By @Philpax - about 5 hours
Linus was a hypocritical asshole here, but more to the point, why are they using strings for this anyway? No byte arrays / literals in their C dialect?
By @Incipient - about 4 hours
This is definitely unexpected for me - I'd have thought something like an RC for a kernel would have to be 'approved' for release only after passing all tests, which should include building with all official compilers (and all official architectures, etc).

Unless either the older GCC or the beta GCC isn't "official"? In which case that's not necessarily expected to be picked up in an RC?

By @jey - about 7 hours
That the annotation applies to variables and not types is surely an oversight or mistake right? Seems like it could have been easier to initially implement that way but it just doesn’t seem to fit with how C type system works. (Yes it will make declarations uglier to do it on types but that ship has sailed long ago; see cdecl.org)
By @mastax - about 2 hours
It’s still shocking to me that there’s no official kernel CI.
By @bjourne - about 2 hours
Err... we teach C neophytes that you should never write values to variables that are larger than what the variables can hold. Don't write an int to a short, don't write a short to a char, and don't initialize five bytes to an array storing four bytes. Am I missing something here? char foo[4] = "ABCD" is always incorrect, no ifs and buts. If you want "readable" bytes, use character literals. You should never discount the null terminator.