12
\$\begingroup\$

I have some C++ code that I am executing from C# dotnet core 2. In my C++, I am using a third party library. My code builds and runs, but after being executed a few million times (2.5 mil last time) I see the following message:

 terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create
Aborted (core dumped)

Now I would like to put my code up here for review, but I don't really understand if it would be against the broken code policy. It might not be broken, because as far as I know the error is being thrown from the third party lib (although as a pretty new C++ dev, I am assuming it's my fault). Would posting this for review be appropriate?

\$\endgroup\$
14
\$\begingroup\$

If that message isn't the intended behavior, and you're looking for a solution to that specific issue, the right thing to do is to post a MCVE that reproduces the problem on Stack Overflow.

If that message isn't the intended behavior, and you don't care for a fix because executing a few million times isn't your use-case anyway, then you don't even need to mention it.

The purpose of the "no broken code" rule is to avoid turning reviewers into bug-hunters. It's about what the intent of your post is: if you want to improve your code in every aspect, you're at the right place. If you want to fix a specific issue with your code, you'd better ask on SO.

If you're worried about that problem, then you need a fix for it - it's a SO question.

If you're not worried about that problem and don't care to fix it and your code works as intended in the intended use cases, then you have a CR question - it's possible that a reviewer finds a bug (or two!) in your working code; it's possible a reviewer finds the source of that bug.

But you can't ask reviewers specifically about it.

\$\endgroup\$
  • 4
    \$\begingroup\$ Since my intention was to validate whether I have a bug first and then make sure it is efficient as possible, I will go to so first then come back here. (not back to meta) \$\endgroup\$ – Theyouthis Sep 8 '17 at 13:51
1
\$\begingroup\$

Since this is an error that stops your code, it's likely to be off-topic as broken code. However if the error is in the third party code, you can say third_party.error_after_2m_calls errors on occasion. And you are not asking for debugging help. (There isn't a meta question for this, but I've asked a question that has this, and know of more that have too)

If however the error is in your code there are three routes you can go:

  • You could ask to fix your error.

    It seems like your error could be in the 'allowed errors' list, which is mostly just memory and performance problems. However, it also seems like one of the 'have you even tried debugging your code' questions. And so may be closed very quickly if you were to ask, and it's something simple. However this list is vague, and so your question is still likely to be closed.

  • You could ask to ignore the error.

    When asking the question, if you're upfront about the error, and say that you want a review of any and all of your code excluding the error. Then it's likely you'll be ok. I've seen these be on-topic, however again there's not a meta question for these, and so there's a chance your question will be closed as off-topic.

  • You could fix the error.

    Since there's no guarantee that your question would actually be on-topic. The safest thing to do would be to locate the error and fix it, if you make an MVCE you could post on Stack Overflow, and then post the fully working code here.

\$\endgroup\$
  • 1
    \$\begingroup\$ "I'm unsure if your problem is just a warning message, or if your code actually errors out and stops working." std::terminate aborts a program. It's essentially a crash at that point, since there's an uncaught exception. \$\endgroup\$ – Zeta Sep 8 '17 at 13:51
  • \$\begingroup\$ @Zeta That's good to know thanks, I'll have to change that part of the answer. :) \$\endgroup\$ – Peilonrayz Sep 8 '17 at 13:54

You must log in to answer this question.

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