News for hackers. Stuff that matters.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by dzsekijo on Thursday June 18, 2020 @09:33AM (#23562930)
Well some aspects are still not clear. If this thing was originally called "segmentation violation", who, when switched to calling it "segmentation fault"? Why we don't get

    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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by tankenmate on Thursday June 18, 2020 @09:41AM (#23563005)
The reason is that the term "fault" is used is because on the PDP range of computers (the first computers to run Unix) when a instruction (op code) fails it creates a "fault". In the case of accessing a segment that no longer exists, or beyond the length of the segment, etc the instruction that tried to execute but failed is said to have "faulted", or suffered a "fault". So an instruction that faults due to a memory segment issue is called a "segment fault" and one that faults due to a memory page issue is called a "page fault". In the case of segment, the name stuck even though almost all modern CPUs have pages rather than segments.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by tankenmate on Thursday June 18, 2020 @09:45AM (#23563029)
This leads on to demand paging, when an instruction tries to access a page that isn't loaded in memory (say for example the page has been "paged out" to swap), then when the instruction faults, it traps into the kernel page handler, and the kernel then determines that yes, the program does own that page and that it is indeed in swap, the kernel will then "page in" that page, i.e. read it from the swap partition and put it in memory. Once the IO has completed and the page is in memory then kernel will reschedule the process and start the execution from the instruction that previously failed. Now that the page is in memory the instruction should execute normally and the process will continue unaware that some of its memory wasn't in RAM but now it is.

[EDIT] fixed a typo.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by gumby on Thursday June 18, 2020 @03:50PM (#23567118)
"Faulting" was a general term (has it fallen out of favor?) when an instruction didn't execute properly and wasn't specific to DEC machines. Hence page faults, as you note.

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!

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by kazinator on Thursday June 18, 2020 @10:54AM (#23563633)
Actually, the "segmentation" comes from segmented memory management, which was integrated into in AT&T Unix. BSD went with paged virtual memory, and there we get "fault" from "page fault", which is an often correctable situation that is invisible to the application, but is sometimes an access violation.

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.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by rob74 on Thursday June 18, 2020 @11:35AM (#23564045)
"hr" is Croatian, Hungarian would be "hu" (and no doubt it sounds cool too).

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!

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by zvrba on Thursday June 18, 2020 @12:15PM (#23564536)
> "hr" is Croatian, Hungarian would be "hu" (and no doubt it sounds cool too).

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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by pantalaimon on Thursday June 18, 2020 @02:30PM (#23566096)
Localized error messages (that are still full of jargon) are terrible. It makes looking them up online much harder and often the translation does not more than obfuscation.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by necovek on Friday June 19, 2020 @01:17AM (#23571216)
The goal of "izbačena" here is clearly to indicate that the memory has been stored elsewhere. FWIW, "dumping trash" would be readily translated to "избацити смеће" (izbaciti smeće) in Serbian, so I am surprised it's such a stretch in Croatian. Perhaps the Croatian translation has been based off Serbian one.

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 :)).

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by zvrba on Friday June 19, 2020 @01:23PM (#23576707)
Croatian "izbaciti" is closest to this meaning: https://www.merriam-webster.com/dictionary/eject or the phrase "throw out". F.ex., "Izbacivac" [sorry, haven't bothered with setting up HR keys] is the guy throwing out too drunk people from a club.

> "избацити смеће" (izbaciti smeće) in Serbian, so I am surprised it's such a stretch in Croatian

But that's exactly it! You "izbacis smece" and you don't care what happens to it after. Likewise with "izbacivac", he throws out a person and doesn't care what the person does afterwards. You don't "izbacis" something FOR someone to use it after. That's why the translation is bothering me.

Whereas the kernel writes the core FOR THE USER to inspect it, back it up, delete it, whatever.

The closest word I can come up with for English "dump" https://www.merriam-webster.com/dictionary/dump is "ostaviti" ("leave around") ili "(is)pustiti" (in the meaning of "drop", not "flushing the toilet" :D). A better literal translation would thus be "Jezgra pustena." (Like a space probe is "pustena" into space and there it goes.) I guess the authors originally used "dump" because it's kinda random (system-wide config) where it ends up.

The most meaningful translation to Croatian would be, IMHO, "Memorija sacuvana." [or "Memorija spremljena."] ("Memory preserved".)

> I imagine you grew up on English interfaces while speaking Croatian

Indeed. Some professors at the university did use Croatian terms, but everything about it was awfully alien to me. "Thread" would be "dretva". Which is ironic, as the professor explained that it's borrowed and mangled from German, whereas we have a perfectly valid, even nice, Croatian word "nit" that is literally "thread".

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by necovek on Friday June 19, 2020 @02:30PM (#23577466)
Those are all great points, but in English, "dumping" is also used when you want to get rid of something/someone (dump a boyfriend, dump into trash...).

If anything, the translation is too literal, and you are advocating for a better translation for the actual action. It's a common complaint, but it's a hard balance to strike: literal translation is (usually) easier to translate back (not the case here), but a translation that is more descriptive is easier to understand.

I think I am in the same boat as you, in that I usually prefer descriptive translations when a literal one uses a metaphore or concept that's alien to the local culture.

Still, in this particular case, I'd use a less commonly used term (I imagine spremiti/sačuvati is also used for "save") like "zapisana" or "zabeležena", just so there's a better chance to keep 1-1 mapping between English and Croato-serbo-bosnian-montenegrin language.

What English has mostly done was keep using old concepts (like "core" to represent "memory"), or repurposed seldom used words which I always found intriguing. Such approach would require some re-learning for us who grew up on English IT terminology, but every profession has a specialised terminology like that too (I like to bring up the example of maths, where in Serbian it's integral and izvod for integral and differential: always try coming up with a good native word, and if it _is_ good, it will stick :)).

Note that people translating free software are usually volunteers working without much local support, and without an established vocabulary for all these specialised terms, so they will frequently come up with awkward translations.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by necovek on Friday June 19, 2020 @02:35PM (#23577504)
I think I posted while you edited your post so you added a couple of good examples for a better literal translation.

But this is exactly the point, it's hard work, it's not always done by people who understand the actual concepts or history, and they are doing it in their spare time. Imagine spending this much time and saying "I translated one message".

Thus, I'd encourage you to contribute your suggestions upstream :)

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by zvrba on Saturday June 20, 2020 @08:07AM (#23583482)
> Croato-serbo-bosnian-montenegrin language

"In confidence": I miss the days when there was only serbo-croatian and croato-serbian :D (I grew up in Yugoslavia and still remember cyrillic.) Politicizing of the languages is just f*up. It says enough that I understand "urban" (i.e. newspapers/TV) serbian better than heavy croatian dialects from Dalmatia, Istra or Zagorje :p

> integral and izvod

Wow, "izvod" is really nice, I like it :D We used just "derivacija". If I had to guess what some eager translator would translate "integral" to, it'd be something like "ocjeljivanje" :D

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by dzsekijo on Thursday June 18, 2020 @04:08PM (#23567372)
I checked Hungarian, it's simply "core készült" ("core has been made"). I guess they did not want to go too far with translating "core" as possible faithful translations would collate with expressions for ejaculation...
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by schoen on Thursday June 18, 2020 @01:02PM (#23565118)
> Estonia gets a cool one:

Sad to say that's also not Estonian -- it's Esperanto. :-)

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by cat199 on Thursday June 18, 2020 @12:24PM (#23564667)
didn't go too deep on the code spelunking, but v7 Unix (and 2BSD) used 'swapping' rather than paging, where the whole process was moved in/out of RAM, 32V (32bit v7 for the vax by AT&T) kept this, 3BSD (32V++ in a way) added paged memory, and this was reworked in 4.3BSD (see 44doc newvm), Mach VM, etc.

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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by necovek on Friday June 19, 2020 @01:27AM (#23571275)
When I played with IA32 in assembly, I think it was possible to swap segments in and out as well (you could order actual printed IA32 books from Intel for free, which was great for a high-school student in Serbia in late 1990s ;)). It was a long time ago, so maybe I am misremembering things.

Thus, I always considered "paging" a shorthand for "swapping of memory pages".

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by kazinator on Friday June 19, 2020 @11:57AM (#23575720)
The term "swapping" originally comes from the multiprogramming technique of exchanging an entire program in memory, and its data, for another program and its data (without any virtual memory support).
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by WesolyKubeczek on Thursday June 18, 2020 @12:00PM (#23564364)
eo is Esperanto, Estonian looks like a version of Finnish.

(so does Hungarian, as sibling has pointed out)

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by twic on Thursday June 18, 2020 @09:40AM (#23563001)
The violation is what the program did. A fault is the handler that runs when the program does something funny. Like with a page fault.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by fsckboy on Friday June 19, 2020 @12:42AM (#23571033)
this is the right answer. I'd tweak it a little, a fault is an interrupt, in this case a hardware interrupt, and the message prints because there is no handler for it (except the default handler that prints the message and halts the program)
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by zoomablemind on Thursday June 18, 2020 @09:21PM (#23570054)
DEC VMS equivalent of this is 'Access Violation', which as such is a Fault, and manifests itself in logs as the dreadful ACCVIO, though one is always hopeful it's debuggabble, unlike 'AST fault' (where AST stands for Async System Trap, which is not a Fault, but the fault happened while trying to deliver the AST...), meant a lot of head scratching and likely call to support. The worst by far is a 'Machine Check', next thing one hopes to see is the carrots >>> prompt on reset.

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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by commandlinefan on Thursday June 18, 2020 @09:39AM (#23562981)
Well, it's less intrusive to change the text than to change the constant.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by monktastic1 on Thursday June 18, 2020 @09:37AM (#23562966)
I've always thought of it like a geological fault, where the two sides are misaligned. But this only fits in the case of misaligned memory access, and not in the more general case of accessing illegal locations.

There's also the tennis fault. It's a noun corresponding to the adjective "faulty."

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by klodolph on Thursday June 18, 2020 @11:24AM (#23563935)
The fault can be corrected. The term “violation” seems to imply that it can’t be corrected. Your program only crashes if the segmentation fault isn’t corrected.
Re:Why is there a “V” in SIGSEGV Segmentation Fault? by fsckboy on Friday June 19, 2020 @12:48AM (#23571061)
trying to fetch from a memory address outside of your boundaries is a violation of a program's contract with the OS. It can't be "corrected" by the OS, and if you see the message, the program has not included a handler for it.

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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by klodolph on Friday June 19, 2020 @03:37PM (#23578113)
The program has no such contract with the OS. The only contract is that if you access unmapped memory, you get a segmentation fault, and the relevant signal handler is invoked. The default signal handler terminates the program.

Depending on the program, a segmentation fault may be routine. That’s why it doesn’t make sense to call it a violation.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by fsckboy on Friday June 19, 2020 @04:15PM (#23578468)
in systems with unprotected memory, you would actually access the address; even though you accessed it, it is a violation, the result is undefined. When there is protected memory, what catches the violation is outside of your process space. It is a violation; possibly I should not have said OS, it's a hardware 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.

Re:Why is there a “V” in SIGSEGV Segmentation Fault? by klodolph on Friday June 19, 2020 @04:24PM (#23578540)
As the article notes, the -V suffix is a historical curiosity. Since no contract is being violated here, the term “violation” does not make sense. This is nothing more than a fault condition, like trying to open a file that does not exist or trying to go to a webpage that does not exist.

The contract with the OS is that if you access unmapped memory, your program is sent SIGSEGV. Just like the contract with open() is that it returns -1 if the file is not found.