Errors, bugs, questions - page 822

 
falkov:

Yes, of course, so what. I've put the place through all sorts of checks.

I know the place, I don't understand why it happens!

I check the array size before this line and other variables for outliers.

But still the Expert Advisor crashes a couple of times a week.

This is most likely my mistake, and I'm not against it. I'm against the fact that I don't have any mechanisms to find out where the dog is buried.

At the same time, there is a simple and convenient exclusion mechanism. They were introduced just for such cases.

Renat answered me that if they introduce this mechanism, unwise programmers will immediately start to make mistakes and they will have to clean it up.

That's a ludicrous argument, in my opinion.

Well, MetaQuotes position on exceptions is well known and irrevocable (I discussed it with them myself 2 years ago), so we just make do with what we have. It would have been more useful if some of your source had been shown.
 

By the way, as an alternative to exceptions, you could implement a simple OnError event handler, like this:

bool OnError(uint errorcode, string filename, uint lineno, uint colno, string context)
{
  ...
  if(critical)
  {
    return(true); // для подтверждения остановки выполнения скрипта
  }
  else
  {
    return(false); // для продолжения выполнения на чарте (текущий вызов прерывается, но следующие тики/таймеры и пр. работают)
  }
}
 
Use the built-in code checker, the same assertions.
 
marketeer:

By the way, as an alternative to exceptions, you could implement a simple OnError event handler, like this:


I think that would have satisfied me, though not completely, as I would have needed to declare the required variables as global to be visible in OnError.

But I'd be happy with it anyway. Sometimes you just need to catch an error, after finding and fixing the problem you can hide them in the local again.

How would one convey this idea about OnError to Renat?

 
falkov:

I think it satisfied me, though not completely, because it would have been necessary to declare the required variables as global to be visible in OnError.

But I would have been happy with it anyway. You just need to catch an error sometimes, after finding and fixing the problem you could hide them in local again.

How to get this idea about OnError to Renat?

Not as a matter of principle. If a program runs into a critical error, its fate is only to be unloaded.

Each important function has return codes, everything is detailed. Therefore, the developer doesn't lose control over his program.

ps: it's amazing of course to hear "not enough!" even after a clear indication of the mis-indexing location.

 
TheXpert:
Use the built-in code checker, the same assertions.

Well, the situation here is different. A person has a sporadic error (reproduced rarely under unclear conditions). The Expert Advisor crashes anyway. If he sets Assert, he will get the same error but not immediately and it will not be clear why. That's why I'm asking him to show me the code.

And lastly, it might be helpful if such errors that cause the script to stop would be accompanied not only by location, but by full context: call stack, variables contents etc. You can make such an output optional using preprocessor directive, i.e. specify error diagnostics level: leave it as is by default but allow to be similar.

Документация по MQL5: Основы языка / Препроцессор
Документация по MQL5: Основы языка / Препроцессор
  • www.mql5.com
Основы языка / Препроцессор - Документация по MQL5
 
marketeer:

Well, the situation here is different. A person has a sporadic error (reproduced rarely under unclear conditions). The Expert Advisor crashes anyway. If he sets Assert, he will get the same error but not immediately and it will not be clear why. That's why I'm asking him to show me the code.

And lastly, it might be helpful if such errors that cause the script to stop would be accompanied not only by location, but by full context: call stack, variables contents etc. It is possible to make such output optional using preprocessor directive, i.e. to specify error diagnostic level: leave it as it is by default, but make it optional.

The full context can be traced during debugging.

Another thing is that sporadic errors must be caught at certain fragments.

And that's where the need comes in. Run debugger on history.

The problem is old and has been raised many times, but it's still there.

 
marketeer:

Well, the situation here is different. A person has a sporadic error (reproduced rarely under unclear conditions). The Expert Advisor crashes anyway. If he sets Assert, he will get the same error but not immediately and it will not be clear why. That's why I'm asking him to show me the code.

95% of sporadic errors are related to initialization errors or lack of it. So, a code fragment will not help and the whole code will not be helpful because of paranoia ;-)

The reason should be sought very far from the place of manifestation, and it is boring for aphthar to just demand that the developers get shot. It will help for sure.

// It will really help, falkov ? : )

 
Urain:

The full context can be traced by debugging.

Another thing is that sporadic errors should be caught at certain fragments.

And that's where the need arises. Run debugger on history.

The problem is old and has been raised many times, but it is still there.

Also true, it would help a lot regardless of the nature of the error.
 
marketeer:

Well, the situation here is different. A person has a sporadic error (reproduced rarely under unclear conditions). The Expert Advisor crashes anyway. If he sets Assert, he will get the same error but not immediately and it will not be clear why. That is why I asked him to show me the code.

There is no point in showing the code, because there is quite complicated logic, who needs to understand it, and the error section itself is simple, but it gives nothing to find the error, there is a half screen of pure code. Each variable is checked for bounds at the bottom and at the top. If the variable exceeds these limits, a message is displayed listing all variables and their values. Of course there is an error somewhere, but that's where!!! Let me remind you that it happens once or twice a week. The Expert Advisor has been working around the clock.

And then I'm interested not only in this particular case, though it's my first time.

And one last thing, maybe it would be useful if such errors which cause the script to stop, were accompanied not only by location, but with full context: call stack, variables contents etc. You could make such output optional using preprocessor directive, i.e. specify error diagnostic level: leave it as it is by default, but allow to increment it.

That would be great! A full context would certainly allow me to find the error! What I need is to look at the variables at the time of the error, before the Expert Advisor leaves.

Dear Renat! Maybe you can do this?

Reason: