I have some broken code (it was working until I made too many changes, and didn't save the original!!). I won't upload it as it is 1,000's of lines long, across many files and classes. Anyway, the result is that MT5 dies after calling a simple return statement (the result in this case is a long).
I can't find any obvious coding errors, so now I have a bunch of questions.
Question 1 - Does MT5 generate a crashlog, as I have been unable to find one?
I have found a metaeditor.log file in the MT5\logs folder, and the cause of the issue appears to be this...
...but that doesn't get me very far without further information.
Question 2 - Is it possible to generate a map file to aid debugging?
Question 3 - Are there any developer tools that can be used to help debug issues such as this?
Failing any of the above, are there any tutorials on this type of subject. I did come across this https://www.mql5.com/en/articles/1414 but that is based on MT4, and having a crashlog available.
Are you getting the same memory addresses every time?
0000021D330A0010
0000001F36CFA2A1
Just in case you have a some sort of hardware fault try running on another terminal and see if the same issue occurs
Are you getting the same memory addresses every time?
Just in case you have a some sort of hardware fault try running on another terminal and see if the same issue occurs
Hi R4tna C,
No the addresses are different...
2 2022.06.29 14:11:11.640 MQL5 debugger failed to read memory with error 299 2 2022.06.29 14:11:11.640 MQL5 debugger failed to read memory (8 bytes from 000002B13EA50010) 2 2022.06.29 14:12:10.809 MQL5 debugger failed to read string length (0000005DCA2FA4A1) 0 2022.06.29 14:12:19.216 MQL5 debugger disconnected 2 2022.06.29 14:12:42.599 MQL5 debugger failed to read memory with error 299 2 2022.06.29 14:12:42.599 MQL5 debugger failed to read memory (8 bytes from 00000170CE970010) 0 2022.06.29 14:15:20.611 MQL5 debugger disconnected 2 2022.06.29 14:15:25.363 MQL5 debugger failed to read memory with error 299 2 2022.06.29 14:15:25.363 MQL5 debugger failed to read memory (8 bytes from 0000021D330A0010) 2 2022.06.29 14:19:08.435 MQL5 debugger failed to read string length (0000001F36CFA2A1) 0 2022.06.29 14:19:36.181 MQL5 debugger disconnected
These issues are always a pain to debug :-(
It was working OK until I made a bunch of changes.
I have tried to modularise the code as much as possible, so I could do a program tear-down and then work through the code, but it just takes so much time :-(

- www.metatrader5.com
Thanks Vladimir,
I do actually have backups in several places including NAS, USB, Dropbox, etc, as well as several other locations, but I was pressed for time and needed to get something finished. At the end of the day it is my own fault for not following good programming practices!
However, now that I am in this mess it would be good to understand what tools are available (if any) to help fix the problem.
Thanks Vladimir,
I do actually have backups in several places including NAS, USB, Dropbox, etc, as well as several other locations, but I was pressed for time and needed to get something finished. At the end of the day it is my own fault for not following good programming practices!
However, now that I am in this mess it would be good to understand what tools are available (if any) to help fix the problem.
The MQL storage is very good but I also find it good practice to take secondary & tertiary backs (zip files to cloud) - so you are half way there!
Yeah I have cloud as well :-)
Just wish I hadn't been in such a rush!
Oh well...
Just a quick update on this issue that I was having. So, my code was calling this...
Select();
...which it turn called this...
void EmbeddedChart::Select(bool selected=true) { color clr = (true) ? clrLemonChiffon : clrLightGoldenrod; SetChartProperty(CHART_COLOR_BACKGROUND, clr); }
...which it turn called this...
void BaseChart::SetChartProperty(ENUM_CHART_PROPERTY_INTEGER propertyID, long propertyValue) { long chartID = GetChartID(); ChartProperty::Set(chartID, propertyID, propertyValue); }
...which it turn called this...
static void ChartProperty::Set(long chartID, ENUM_CHART_PROPERTY_INTEGER propertyID, long propertyValue) { ResetLastError(); if (!ChartSetInteger(chartID, propertyID, propertyValue)) { PrintFormat("Failed to set chart integer property [%s]. Error code [%d]", EnumToString(propertyID), GetLastError()); } }
Now, If I called the Select() function from any of the other locations that I tried, it worked as expected. However, pressing F10 to return from the following method (in its current location in the codebase)...
void EmbeddedChart::Select(bool selected=true) { color clr = (true) ? clrLemonChiffon : clrLightGoldenrod; SetChartProperty(CHART_COLOR_BACKGROUND, clr); }
...resulted in the debug stack (in the debugger window) disappearing, and the app terminating with the failed to read memory with error 299 error in the log.
After several days of no luck tracking this issue down, I took another copy of the code in its current state, deleted the app, and then rebuilt the app, one file at a time, compiling each file as I went. When everything was rebuilt, I ran the app and everything is now working as expected...grrr!
At this point, I can only assume that a file was either built out of step, or an old file was not rebuilt when rebuilding the indicators and EA.
So my questions are...
Question 1) Can it get into this state?
Question 2) Do I need to do anything in particular (or is there anything that I can do) to make sure that everything gets rebuilt, and in the correct order so that this problem doesn't happen again (BTW all files had been saved.)?
Finally, repeating the question that I asked at the start of this issue, are there any developer tools that can be used to help debug issues such as this?Just a quick update on this issue that I was having. So, my code was calling this...
...which it turn called this...
...which it turn called this...
...which it turn called this...
Now, If I called the Select() function from any of the other locations that I tried, it worked as expected. However, pressing F10 to return from the following method (in its current location in the codebase)...
...resulted in the debug stack (in the debugger window) disappearing, and the app terminating with the failed to read memory with error 299 error in the log.
After several days of no luck tracking this issue down, I took another copy of the code in its current state, deleted the app, and then rebuilt the app, one file at a time, compiling each file as I went. When everything was rebuilt, I ran the app and everything is now working as expected...grrr!
At this point, I can only assume that a file was either built out of step, or an old file was not rebuilt when rebuilding the indicators and EA.
So my questions are...
Question 1) Can it get into this state?
Question 2) Do I need to do anything in particular (or is there anything that I can do) to make sure that everything gets rebuilt, and in the correct order so that this problem doesn't happen again (BTW all files had been saved.)?
Finally, repeating the question that I asked at the start of this issue, are there any developer tools that can be used to help debug issues such as this?Ouch!
1. Such problems can happen with any system - I have had serious issues with major vendors such as SAP, Oracle, IBM, Sun, etc. Usually you never find out why and have to restore or re-build.
2. Enable MQL cloud storage/version control and take separate backups too in parallel

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have some broken code (it was working until I made too many changes, and didn't save the original!!). I won't upload it as it is 1,000's of lines long, across many files and classes. Anyway, the result is that MT5 dies after calling a simple return statement (the result in this case is a long).
return (result);
I can't find any obvious coding errors, so now I have a bunch of questions.
Question 1 - Does MT5 generate a crashlog, as I have been unable to find one?
I have found a metaeditor.log file in the MT5\logs folder, and the cause of the issue appears to be this...
...but that doesn't get me very far without further information.
Question 2 - Is it possible to generate a map file to aid debugging?
Question 3 - Are there any developer tools that can be used to help debug issues such as this?
Failing any of the above, are there any tutorials on this type of subject. I did come across this https://www.mql5.com/en/articles/1414 but that is based on MT4, and having a crashlog available.