BugRequest: "Access violation" while accessing static function

 

Hey all,

i have something really strange. I have some code and each time i access this function i get this error:


2018.11.19 17:51:48.897 Test  (EURUSD,H1)       Access violation at 0x000002A0178243A0 write to 0x000002A0178243A0
2018.11.19 17:51:48.898 Test  (EURUSD,H1)          crash -->  memory at 0x000002A0178243A0 is not readable
2018.11.19 17:51:48.898 Test  (EURUSD,H1)       00: 0x000002A0178243A0
2018.11.19 17:51:48.898 Test  (EURUSD,H1)       01: 0x0000029E1785E1C1
2018.11.19 17:51:48.898 Test  (EURUSD,H1)       02: 0x0000000000000075
2018.11.19 17:51:48.898 Test  (EURUSD,H1)       

If i put some more "random" code which i don't use , than the error disappier. There is no compiler error, nor forgotten resizing array to correct length. Non of the source data in this specific function has changed.

I just added a Print() line. When i remove it, the error comes back.


Do you have any idea what this could be ?

Thanks & Regards, Chris

 
Christian Stern:

I just added a Print() line.

"No strings attached." - MetaTrader 5 probably.

Update to latest beta and try again.


If you already have latest beta or bug persist after the update report it here:

https://www.mql5.com/ru/forum/285631

Новая версия платформы MetaTrader 5 build 1930: Плавающие окна графиков и .Net библиотеки в MQL5
Новая версия платформы MetaTrader 5 build 1930: Плавающие окна графиков и .Net библиотеки в MQL5
  • 2018.10.25
  • www.mql5.com
26 октября 2018 года будет выпущена обновленная версия платформы MetaTrader 5...
 
kypa:

"No strings attached." - MetaTrader 5 probably.

Update to latest beta and try again.


If you already have latest beta or bug persist after the update report it here:

https://www.mql5.com/ru/forum/285631

of course i have added a string .. just would not write the entire line.
 
Christian Stern:

Hey all,

i have something really strange. I have some code and each time i access this function i get this error:


If i put some more "random" code which i don't use , than the error disappier. There is no compiler error, nor forgotten resizing array to correct length. Non of the source data in this specific function has changed.

I just added a Print() line. When i remove it, the error comes back.


Do you have any idea what this could be ?

Thanks & Regards, Chris

What build ? What code ?
 
Alain Verleyen:
What build ? What code ?

Hey Alain,


i try to use always the latest, currently V5.0, 1947. The function is from a static class which returns a pointer of a object

static bool CPointer::getPointer( string objectname, CFooBar* &pointer ) 


Before i return the pointer, i check if all if fine:

if ( GetPointer(pointer) == NULL || CheckPointer( pointer ) == POINTER_INVALID ) {
   Print("Unable to create object pointer: "+objectame+" !");
   return false;
}else{
   Print("CPointer","       ...successful initiated.");
   return true;
}


Before i just returned, true and false with a error msg. But somehow now it crashes. To track down the error i put some printing lines and the error was gone. When i remove the "successful initiated" line, it panics again without changing other code. I reproduced the error a lot and it is nothing magic what i do there. Just had to uncomment the "print successful" line.

Restart all didn't helped too.


Regards, Chris

 

Update ...it looks like it has something to do with the size of the program. It was gone for some hours and now it is back. I have uncomment the line in the morning and the error was gone.

Now after some coding time, it is back. Same workaround helps.

 
Christian Stern:

Hey Alain,


i try to use always the latest, currently V5.0, 1947. The function is from a static class which returns a pointer of a object


Before i return the pointer, i check if all if fine:


Before i just returned, true and false with a error msg. But somehow now it crashes. To track down the error i put some printing lines and the error was gone. When i remove the "successful initiated" line, it panics again without changing other code. I reproduced the error a lot and it is nothing magic what i do there. Just had to uncomment the "print successful" line.

Restart all didn't helped too.


Regards, Chris

GetPointer(pointer) == NULL

This seems useless (wrong ?) as your "pointer" is already a pointer.

Anyway a crash is an MT5 bug of course. Yesterday I had one while with "delete pointer" when pointer was invalid (it's supposed to log an "invalid pointer to delete" message.

 
Alain Verleyen:

This seems useless (wrong ?) as your "pointer" is already a pointer.

Anyway a crash is an MT5 bug of course. Yesterday I had one while with "delete pointer" when pointer was invalid (it's supposed to log an "invalid pointer to delete" message.

thanks for the hint, your right. i am always happy to remove unused/inefficent code. Maybe it sneaks in somewhere in the past. anyway it panic's again. I had yesterday same panic in another array with 2 objects per entrie. 9/22 of the could be deleted cleanly than the panic pops up.

Thats not cool because it lefts a open database. Is there anyway to track down the error ? debugger ? verbose ..something where i get more infos.

 
Christian Stern:

thanks for the hint, your right. i am always happy to remove unused/inefficent code. Maybe it sneaks in somewhere in the past. anyway it panic's again. I had yesterday same panic in another array with 2 objects per entrie. 9/22 of the could be deleted cleanly than the panic pops up.

Thats not cool because it lefts a open database. Is there anyway to track down the error ? debugger ? verbose ..something where i get more infos.

Did you check your pointers before deleting ? Please show the code.

 
Alain Verleyen:

Did you check your pointers before deleting ? Please show the code.

Some how it is gone again. Maybe it has something to do while i've reduced the number of entires in this array. I've also removed all the GetPointer() at destruct level. I'am not sure if i should use CheckPointer(). The objects will be always initiated.

 
Can it be that EAs and indicators compiled before Beta build 1930 will occasionally crash on terminals build 1930+?
Reason: