by dzsekijo · 6y ago · 0 comments
Segmentation violation (core dumped)
when this thing fires?Actually "violation" sounds much clearer to me. It's telling me that the code I'm running does something that was not part of the contract. With "fault"... well, it's someone's fault... probably someone else's fault... who knows what happened... ¯\_(ツ)_/¯
I wouldn't be surprised if it was found out to sound smoother to managerial ears.
[EDIT] fixed a typo.
Neither PDP-7 (original Unix machine) nor PDP-11 had segmented memory. Segmentation was fundamental in the design of Multics, and I suspect the term, if not the signal itself of course, was carried over from there. Memory segmentation was pretty common back then, though far from universal.
By the way there were a lot of machines under the "PDP" umbrella with some vary different architectures. PDP-1, -7, and -9 had 18-bit words; PDP-5, -8 and -12 had 12-bit words; the PDP-6, -10 (and renamed from PDP -20) had 18-bit addresses and 36-bit words; and the PDP-11/LSI-11 had 16-bit words (this was later pumped up into the 32-bit VAX line). Unix only really ran on the 11s (and VAXes which BTW gave us the MIPS metric) apart from the one PDP-7 development machines. We used a variety of Ones on all those machines, often homegrown.
In those days it was quite common for a company to write their own OS and programming language just for their computers, and for their customers to do the same!
So "segmentation fault" is a weird combination of terms.
And of course "core" is from "magnetic core memory" that nobody uses any more.
The SIGSEGV constant having come from AT&T Unix propagated into other variants, for the sake of source code compatibility, even though those other variants didn't use segmented memory.
I suspect that what happened was that hackers not working with segmented memory at all somehow adopted the "segmentation" term from the AT&T code and documentation, but did not warm up to the "violation" part, sticking with the "fault" terminology of their paged world.
The "Segmentation fault" string you see displayed by the shell comes from the strsignal function that maps signals to descriptive strings. I think that originated in BSD Unix. "(core dumped)" is locally generated by the shell if that flag is true in the process status.
Bash internationalizes that with gettext. Here it is in Hungarian:
po/hr.po:msgid " (core dumped)"
po/hr.po-msgstr " (jezgra izbačena)"
Estonia gets a cool one: po/eo.po:msgid " (core dumped)"
po/eo.po-msgstr "(nekropsio elŝutita)"
Trivia: very early Linux kernel versions used 80386 segments for processes.And yeah, a "necropsy" (synonym for autopsy) definitely sounds cooler than a "dump"...
Otherwise: great summary, almost more interesting (and more compact) than the original blog post!
And the translation is abysmal: "jezgra" = "core" (of nuclear reactor) or "nucleus" (of an atom); the closest translation for "izbačena" is "ejected". I believe that "core" comes originally from memory technology of the time (https://en.wikipedia.org/wiki/Magnetic-core_memory) so it should have been possible to find a more meaningful translation.
EDIT: As a native Croatian speaker, I have NEVER used any program in Croatian locale. It is simply unintelligible. Funnily, I find Norwegian (where I live now) translations more approachable.
You are probably more accustomed to Norwegian translations because you never learned Norwegian IT-speak before the translations appeared, whereas I imagine you grew up on English interfaces while speaking Croatian (we term that Srblish, maybe you've got Croglish :)).
Sad to say that's also not Estonian -- it's Esperanto. :-)
can confirm SEGV is in v7 signal.h from 1979:
https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/si...
where it is happily #defined as 11, and continues as such to this day:
https://github.com/freebsd/freebsd/blob/master/sys/sys/signa...
(etc, in the other BSD-derived systems)
if anyone wants to dig further.
Thus, I always considered "paging" a shorthand for "swapping of memory pages".
(so does Hungarian, as sibling has pointed out)
It's a very nuanced and structured terminology, but does make sense after reading all those hefty and well-written manuals. People like to use those volumes as monitor risers these days, but those are often true standards of quality technical writing. I once was amazed by the clarity, so the VMS doc volume migrated to the shelf in exchange for some old conference proceedings volume of the same heft.
There's also the tennis fault. It's a noun corresponding to the adjective "faulty."
If the program wishes to do something different, it can register a handler, and you won't see the message. If you see the message, there was a violation. If you don't see the message... well, there was still a violation, but it got handled.
Depending on the program, a segmentation fault may be routine. That’s why it doesn’t make sense to call it a violation.
I'm not the only one who says this, look at the name, -V
edit: actually, though hardware support is required for certain OS features, it's the OS that sets up the segmentation and the fault handlers so ... it is ultimately an OS contract.