2 ms·
The only correct answer would be "you dereference a null pointer". That is the only part of this equation the c language interacts with. That's the entire reaso
by gravypod 7y ago
The only correct answer would be "you dereference a null pointer". That is the only part of this equation the c language interacts with. That's the entire reason SIGSEGV is a signal to your process. Page faults or access violations are manifested as interrupts in most systems. In some systems there are no such restrictions. Even in C & x86 within RING 0 you should be able to access ((char )0). I've even made an example branch on an old kernel I was making when I was in highschool to test this and it does work [0].
What is unfortunate is that everyone is looking for a different kind of person. If I'm applying to a job, saying "segfault" might be the right answer OR it will be the wrong answer and the interviewer will leave thinking I don't know how this fundamental functionality (in some industries) works. I could also give the more correct answer and look like a know-it-all which, when I'm trying to sell myself based on what I know, is somehow a bad thing.
It's a loss no matter which way I play it.
I distinctly remember one interview where someone asked me to define a RESTful API for a chat service. So I naturally defined the different objects (ChatRoom, Message, User) and defined what CREATE, LIST, DELETE on them all did. The interviewer was confused because CREATE&LIST are not HTTP methods and I explained that RESTful design isn't really coupled to HTTP and these objects and the operations we can perform with them could be implemented over an RPC or HTTP/json and I listed the steps for both of these approaches. He cut the interview short and I never heard from that company again.
[0] - https://github.com/gravypod/Simple-OS/commit/b7a608500b2e70dc0cc2b939ba1bd6381e555bd8#diff-cdd8f39dc4ace4d761440f54b310f2f6R23 https://github.com/gravypod/Simple-OS/commit/b7a608500b2e70d...
- umanwizard 7y agoYou make it sound like there is no right answer, but why couldn't you just explain to the interviewer everything you wrote in this post? "Well, according to the C standard it is undefined behavior. In context X it performs like Y" and so on.