-18

I have a question about my Stack Overflow post: LLVM IR segfaults

My post keeps getting downvoted (other ones to). I would like to know what I am doing wrong and how to improve.

5
  • 11
    You have only one down-vote on that question, just one -- why are you bringing this to meta attention? This can bring more down-votes to the question due to the Meta Effect where asking a question on meta about a stackoverflow question brings additional attention to the question, possibly positive attention and possibly negative attention. I think that it would be much better and wiser for you to just try to first improve the question as per the How to Ask link and ask on meta if the DV count is much higher. Sep 16 at 1:11
  • 4
    And as for that question, I don't know C++, but it looks as though the question could be improved by a lot more detail including background information, debugging information, plus a decent [mre] post of code that fully reproduces the problem. If you have not yet done so, again, go through the How to Ask link as well as the tour and help center links to see how to best use the site. Sep 16 at 1:13
  • 7
    "My post keeps getting downvoted (other ones to)." You asked two questions, which got one downvote each (and a third recently that didn't). "I would like to know what I am doing wrong and how to improve." Did you try reading through the help center and previous Meta posts (for example, the FAQ entry describing closure reasons)? Sep 16 at 1:24
  • And, while I'm far from a LLVM expert, it strikes me as odd, to say the least, that you're using a double as an index field to GEP. That's not allowed, and versions of LLVM I'm familiar with won't even accept it. More details on what you've done to debug this, and where exactly it's segfaulting would be appreciated. Sep 16 at 1:29
  • 12
    I downvoted your question, because I wasn't able to compile your MRE, in order to run it to determine which line threw the segmentation fault. So in other words, a lack of necessary debugging effort, is the reason why I downvoted that particular question. Sep 16 at 1:44

1 Answer 1

13

If a single downvote applied to each of two questions is enough to get your attention and actively seek out feedback - in the place where the people most concerned with the site's quality congregate to discuss policy - then I can only assume you're prepared for harsh feedback. So let's go over the post in detail. (Please keep in mind that you are likely to get more now.)

The following LLVM IR segfaults durring runtime... I have defined printi in a seperate shared object. When 1.000000e+00 is replaced with 0.000000e+00, it works fine.

The main issue here is that these sentences don't constitute a question; they only describe a problem. You imply that you want to know why the code segfaults; but we do not actually debug code here. Before you post, it is your responsibility to try to figure out the problem by carefully examining what happens, step by step. Debugging is the start of the process; it ends with creating an example where you have a clear expectation for what should happen at some point in the program, that expectation is violated, and you don't understand why. Ideally, this process also involves trying to improve that understanding yourself - for example, by using a search engine. (When I try this, I get a vague impression that maybe double 1.000000e+00 doesn't make sense as an argument here, simply because it says double rather than being some integral type, while the instruction seems to be something about indexing arrays.)

I don't actually know anything about using LLVM's IR directly, so I can't meaningfully comment on the code sample. I assume this is a somewhat assembly-like language that requires a fair bit of boilerplate; and you say that you can produce a program that runs (and crashes at runtime) this way; and it doesn't look like there's a lot of calculation here - so I assume this code represents a reasonably good minimal, reproducible example.

Of course, before posting, you should make sure of that - please try it yourself, by copying and pasting out of the post preview without adding or changing anything, and check that you can reproduce the exact problem you're asking about, directly.

Aside from that, there are multiple typographical errors in what you wrote. Before posting, you can see a post preview underneath the text entry, and you can see your browser underline spelling errors. If you will not at least put in a little bit of attention to make sure that literally five sentences of prose are actually right, then why should we expect that you would i) listen to what others have to say; ii) have the attention to detail required to apply suggested solutions and test them properly; iii) have the attention to detail required for debugging, and programming, generally?

Also, what is a good technique for debugging IR?

There are at least two problems here.

  1. If we suppose that the implied question before is what you are actually asking, then this is a separate question. We require one question per post, because questions are supposed to be individual questions that contribute to a reference library - the purpose of posting is not simply to get your code to work.

  2. Even by itself, this is way too broad of a question. There are any number of things you could try doing to "debug IR" - although the obvious starting suggestion is "use a debugger". More to the point, it can't really be answered in a vacuum because it doesn't point at any objective way to judge the answers.

I am trying to learn LLVM.

Cool. We are not interested in you, your level of skill, your interests, your plans for the future or anything else like that; we are interested in the question, because this is not a discussion forum.

You must log in to answer this question.

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