https://stackoverflow.com/questions/33051108/how-to-get-around-the-linux-too-many-arguments-limit/33278482

> I have to pass 256Kb of text as an argument to the "aws sqs"

what, uhhh, what

> MAX_ARG_STRLEN is defined as 32 times the page size in linux/include/uapi/linux/binfmts.h:
> The default page size is 4 KB so you cannot pass arguments longer than 128 KB.
> I modified linux/include/uapi/linux/binfmts.h to #define MAX_ARG_STRLEN (PAGE_SIZE * 64), recompiled my kernel and now your code produces

casually patching the kernel to send a quarter megabyte as a *single* argument oh my god i'm laughing hard
@navi well in the early rust for Linux days we hit this limit with the passing kconfig options to rustc. Fun times

@kloenk @navi Back when 128 kB was the limit for argv+envp, Google was hitting it too because they passed all the configuration for their whole software stack on the command line as --long-option=value switches.

Their solution? Compress the command line. So every binary started by ungzipping argv[1] and parsing it to get the configuration.

The person explaining this to me saw my horrified face, and said with the perfect Hide The Pain Harold smile: "a series of individually completely rational and reasonable decisions led to this." and I have been thinking a lot about it since.

@ska @kloenk @navi What the hell did I just read oh my god, that is TERRIFYING. Yet that is also so ingenious that I don't know how to feel about it

-James
@thecatcollective @navi @kloenk "Brilliant and cursed" applies to way too much software, and I want the exact opposite of that - I want things that work dumbly, simply, elegantly, and that can be understood by mere mortals.
@ska @thecatcollective @navi isn’t technically a OS not being able to be written with C as the C spec defines some required things as UB? So yes that would be nice but sometimes fear we might need new abstraction for some of those types of software we have
@kloenk Excuse the beginner question, but: If operating systems are not to be written in C due to the C spec defining some stuff as UB, how do kernels get away with it?

As far as I know, something being defined as UB means it may work, it may not work, it may do unintended stuff, but then how do they get around this?

-James
@thecatcollective I don’t remember anymore. Think it was something like the C spec not defining some forms of casting or something. Spec is only a document that says please do it like this. But if all compilers just decide to do it the same way even when the spec does not define it in that way

@kloenk @thecatcollective even if only the compiler used for the specific OS kernel does it in a way the source of that kernel expects, it's fine(-ish) - no "all compilers agree" needed

UB really just gives compilers the freedom to do whatever the fuck they want

And while I don't have anything specific to say, from doing kernel dev myself, I'm pretty sure there is some UB I depend on (and lots where I could probably just write better code, but that's a different topic xD)

@thecatcollective @kloenk for the longest time the linux kernel was only buildable with gcc because they relied on undefined behaviour that is defined in gcc (plus obviously gcc extensions to the c language)

it is possible to write an OS with only standard, defined, C though -- but what you do is pull all the ultra low level logic that can't be done in a defined manner (very few things are like that actually) and write that in platform specific assembly

often said logic needs to be assembly anyway so it's all good
@navi @thecatcollective there are still some configs that don’t build with clang (still didn’t get around to send a issue report). Enabling the CONFIG_MATOM option results (in my case at least) in clang exiting with some weird to many registers error

@thecatcollective @kloenk operating systems commonly use features that are provided by the specific compiler(s) that they're developed with, but that are not part of the C language standard. OSes also commonly have small pieces of low level functionality implemented directly in assembly language for their target platforms.

See, for example, https://maskray.me/blog/2024-05-12-exploring-gnu-extensions-in-linux-kernel

@jpab @kloenk We will take a look at this, thank you!

-James