35

Each day we get many questions with a title along the line of "Segmentation fault (core dumped)" followed by some source code with bugs. This is particularly true for questions in the and tags.

A segmentation fault could be caused by anything, see Definitive List of Common Reasons for Segmentation Faults. It literally just means: "It appears that you have a memory-related run-time bug in your program". As it turns out, most bugs are memory-related.

Therefore "segmentation fault" is not a good question title nor is it a good error description. Questions with such descriptions are generally of low quality. Often they are "debug this for me" requests and they often lack an MCVE.


Just as an example, here are all "segmentation fault" questions I could found posted in the C and C++ tags today:

  1. How do I fix a segmentation fault (core dump) in C?
    Closed as it was simple typo/very common FAQ.
    Cause for seg fault: forgot & in scanf.
  2. A macro for printf caused Segmentation fault
    Somewhat incomplete question. The OP would have gotten a better answer with a MCVE.
    Cause for seg fault: most likely not checking if a function returned an error after using it.
  3. Segmentation fault (core dumped) [matrix of pointers] Closed, basically just a wall of code, "debug this for me". It contained many basic FAQ newbie mistakes.
    Cause for seg fault: missing string null termination and array out-of-bounds bugs.
  4. segmentation fault ( core dump)
    Appears to be another debug request with no MCVE, that can't get reproduced.
    Cause for seg fault: no idea, can't reproduce.

I propose that we do something against questions with "segmentation fault", "seg fault" or "sigsegv" in the title, in order to increase the quality of such questions.

(SIGSEGV is the formal name for the signal used by the OS for indicating segmentation faults.)

9
  • 10
    What is the goal of Stack Overflow? "we're working together to build a library of detailed answers to every question about programming". According to the great canonical Q&A you link to, we already have the answer to "What is a segmentation fault?", so any further such question can be closed as a dupe of that one. Or, alternatively, the tour should be altered to state "Together we are a free, online debugging service so you can learn to program".
    – CodeCaster
    Commented Mar 16, 2017 at 14:01
  • 30
    @CodeCaster It is not that easy to dismiss such questions. With the same logic, we could write a canonical post "what is a software bug?" and then close the whole of SO as a duplicate to that one.
    – Lundin
    Commented Mar 16, 2017 at 14:30
  • 4
    If someone asks "why does this code crash", then a bad answer says "because there is a segmentation fault" and a good answer says "because you are returning a pointer to local data from a function". Similarly, if the question title isn't "segmentation fault (code dumped on SO)" but rather "Crash when returning pointer from function", we can easily spot the bug and close the question with a canonical dupe, in this case probably Can a local variable's memory be accessed outside its scope?.
    – Lundin
    Commented Mar 16, 2017 at 14:31
  • 8
    My point was, although slightly tongue-in-cheek, that we shouldn't allow shitty "debug this code for me" questions, regardless of the actual subject. The same applies to NullReferenceExceptions in .NET, "undefined" errors in JavaScript, division by zero errors, and so on. The root cause is always the same, there exist great canonical duplicates that show the basic debugging help someone needs. We don't need any more of such questions, as they are always too localized and useless for others.
    – CodeCaster
    Commented Mar 16, 2017 at 14:34
  • 2
    @CodeCaster Certainly, but these are not always "debug this for me". Or if they are, then perhaps after all it is not too drastic after all to simply block "segmentation fault", "null pointer exception" and similar nonsense titles. Blocking crap before it hits the site is always the ultimate solution, rather than having user moderators manually remove it.
    – Lundin
    Commented Mar 16, 2017 at 14:57
  • 3
    Obvious extension: Windows calls these "Access Violation", code "c0000005". Equally low value questions, generally. E.g. stackoverflow.com/questions/42824544/…
    – MSalters
    Commented Mar 16, 2017 at 17:03
  • 1
    @MSalters Extension #2: nullpointer, null-pointer. Ah, Lundin already beat me to it.
    – Shark
    Commented Mar 16, 2017 at 21:21
  • 1
    A newbie that doesn't really understand what is going on may be doing their best to describe the problem in the question. After all, their system is reporting to them SIGSEGV. We see NPE questions in java all the time. Commented Mar 17, 2017 at 12:39
  • It literally just means: "It appears that you have a memory-related run-time bug in your program" is literally just wrong. A segmentation fault is an access violation. It means that you tried to access memory that you are not allowed to use. It’s not just any memory-related run-time bug, although it might be caused by another such bug, of course.
    – idmean
    Commented Mar 18, 2017 at 8:00

2 Answers 2

37

I think it is perhaps a bit drastic to block users from having these words in the question title, but that's one option as we already have that mechanism in place for words like "problem". But there should at least be some sort of warning or head's up. For example:

"Segmentation fault", "seg fault" or "SIGSEGV" is not a good title nor a good error description. Such faults could be caused by any kind of run-time bug. It basically just means that your program crashed because it contains a bug, which is not a helpful error description.

Instead, try to describe what you did when you got this fault, what you have done to trouble-shoot it so far and where you suspect that the bug might be located. Try to post the problematic code as a Minimal, Complete, and Verifiable example (MCVE).

See also What is a segmentation fault? and Definitive List of Common Reasons for Segmentation Faults.

11
  • 6
    I don't like the idea of putting in restrictions based on specific, technical keywords. Where does it end if we do this? Does every language/tool get a set of words that trigger something? That seems unmanageable in the long run.
    – jpmc26
    Commented Mar 16, 2017 at 22:41
  • 13
    @jpmc26 We already have things like this though, based on tags. If you use sql, it will prompt you to tag a specific RDBMS. Just because we can't hypothetically scale to infinity doesn't mean it can't be part of the solution. Commented Mar 17, 2017 at 1:05
  • The wording should say "you should first follow the instructions under XXX, and then post an MCVE".
    – o11c
    Commented Mar 17, 2017 at 2:45
  • @ChrisHayes - yes, and what a success that's been. Almost every SQL question I seem to see ends up with an early comment along the lines of "please edit your question and add a tag for your database product". Warnings, pop/ups, etc are all just obstacles to people posting their question and people get rid of them as quickly as possible by finding the right button to press. You don't think they're reading them, do you? Commented Mar 17, 2017 at 14:34
  • @Damien_The_Unbeliever If that's not working, then the solution is obviously to block them from posting. For example, if the [SQL] tag is picked, they must also pick one of several listed DBMS or they can't even post the question. Or as in this case, block the post from getting posted if it contains mentioned words in the title.
    – Lundin
    Commented Mar 17, 2017 at 15:08
  • 2
    @Lundin - For the type of users who post the bad titles, they just want to post their question, dag-nammit. The quickest solution for them, on presented with the above message, is just to mispell the "bad words" that some warning message was talking about. Commented Mar 17, 2017 at 15:12
  • @Damien_The_Unbeliever But in that case I don't think there's ever going to be anything we can do. If the user is that committed to posting a bad question, it will always be impossible for us to stop them. However if the user is trying to post a good question, then pushing them in a direction that will decrease the time for them to get a good answer can only be a good thing.
    – Vlad274
    Commented Mar 17, 2017 at 18:45
  • 3
    @Vlad274 - again, consider the type of users where the issue arises. They don't spend time thinking. They don't search for existing answers. They haven't spent time thinking carefully to describe their problem. They've found a Q&A Site where they're determined to post their question and get an answer. The people who would read and react to informational alerts are already far removed from 99% of the question posters. I don't have a ready solution, I'm just suggesting that the proposed remedy will not work. Commented Mar 17, 2017 at 19:10
  • @Vlad274 - or, to put it another way - please link to a well researched/described question where the only fault was that they used one of these words in their title, in the first version. Commented Mar 17, 2017 at 19:19
  • If they just post bad question ignoring all we can do for having them better, we should just close them. After losing time getting rejected, it is likely some of them will end up reading what they should do. So such messages would be useful in my opinion.
    – Frédéric
    Commented Mar 18, 2017 at 16:13
  • Of course it will always be possible to stop people from asking bad questions. It's just a matter of how restrictive the site should be. Ideally the scripts would detect and block bad questions automatically. If that doesn't work out, there's also the possibility of a mandatory, manual review of first-time/low rep posters, where their question has to pass review before it becomes visible on the site.
    – Lundin
    Commented Mar 20, 2017 at 7:31
1

Java seems to have a very similar kind of problem: NullPointerException. And there seems to be a consistent way in which such questions are dealt with most of the time, as demonstrated e.g. in https://stackoverflow.com/questions/36387134/nullpointer-but-where - close it as a duplicate of the canonical answer.

Of course this isn't always the proper way to react - I've seen some NullPointerException questions that were perfectly reasonable to ask and got upvoted and answered accordingly. But for the common case, the canonical answer will either help OP solve the problem, or it will help them understand the problem better so that they can ask a more specific question.

3
  • We already have that for Undefined Reference errors. However, while that canonical dupe already is extremely long and enumerates a ton of possible reasons, a canonical segfault dupe would be much longer, if it can exist. It is basically impossible to enumerate all possible causes of segfaults along with some useful guidance to fix it. So I'm afraid that won't work for this problem.
    – Baum mit Augen Mod
    Commented Mar 18, 2017 at 12:56
  • @BaummitAugen Instead of trying to list all possible causes, is it possible to give a general guidance in how to find out the actual reason (either so that OP can fix it or ask specific question)? Commented Mar 20, 2017 at 7:54
  • No, I don't think so. The commonly used existing tools don't do much more that point out were the offending operation happened, and not even that is working precisely for all causes. You can cover some of the noob mistakes like out-of-bound or double-free stuff (though that will still only tell them the where, not the why), but others like incorrectly creating standard library types with malloc will most likely not be diagnosed correctly by some "general guidance" answer.
    – Baum mit Augen Mod
    Commented Mar 20, 2017 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .