Compiler changes MQL5?

To add comments, please log in or register
John Emans
16
John Emans  

Hi guys & gals,


As of 2017/04/07 the mql5 compiler produces binaries that almost instantly crash with a ' invalid pointer access' (or similar) error.

I can't claim that my code is bug-free, but it has been running for months, if not years, without much problems.

It's hard to give a code-snippet because the offending line is buried under layers of classes, but in essence it is something like:


        #define  HISTORYLENGTH 10000

        CANDLE  candles[HISTORYLENGTH];  // CANDLE is very simple class with open, close, date ...

                
       CANDLE  *nipCandle(int bar=1)          {                      
           return GetPointer(candles[(bar+HISTORYLENGTH)%HISTORYLENGTH]);         
       }


     nipCandle(0) ; //  <--  this statement crashes with a 'invalid pointer access'






So my questions:

* Is anyone aware of major changes in the MQL5 compiler?

* Is this the right place to discuss compiler problems?

Alain Verleyen
36141
Alain Verleyen  

Only 2 possibilities :

  • It's a bug in your code : nobody can help without a code that compiles and reproduce the issue.
  • It's an MT4/MT5 bug : then you need to write to ServiceDesk. They will ask you a "code that compiles and reproduce the issue."
John Emans
16
John Emans  

I found a short working example that demonstrates the problem and sent it to the ServiceDesk.

In case anyone is interested:



#define  HISTORYLENGTH 10000


////////////////////////////////////////////////////////////////////////
class CANDLE {

public:    
   
      double            open;   // open price
      double            close;  // close price
      double            high;   // high price
      double            low;    // low price
      datetime          date;   // date

     
        
     
};


/////////////////////////////////////////////////////////////////////
class CANDLESf {

public:

       CANDLE  candles[HISTORYLENGTH];


public:

 
       CANDLE  *nipCandle(int bar=1)   {                  
         return GetPointer(candles[bar]);         
       }
    

};


int OnInit() {
 
    printf(__FILE__+"  "+__FUNCTION__+" Compiled at: "+string(__DATETIME__ ));        
 

    CANDLESf *c= new CANDLESf;

    CANDLE *p=c.nipCandle(0);
   
    p.open=1.005; // <- This generates the 'invalide pointer access' error

    return(INIT_SUCCEEDED);
  
  }


this produces the following error:


NN    0    12:33:26.345    History    USDCAD,M10: history begins from 2015.01.02 09:00
IJ    0    12:33:26.347    Tester    USDCAD,M10 (MetaQuotes-Demo): OHLC bar states generating. OnTick executed on the bar begin only
PG    0    12:33:26.383    Tester    USDCAD,M10: testing of Experts\IPA.ex5 from 2016.04.27 00:00 to 2017.04.28 00:00 started
OG    0    12:33:26.415    IPA (USDCAD,M10)    2016.04.27 00:00:00   IPA.mq5  OnInit Compiled at: 2017.04.13 12:33:11
ES    2    12:33:26.415    IPA (USDCAD,M10)    2016.04.27 00:00:00   invalid pointer access in 'IPA.mq5' (53,5)
JM    2    12:33:26.415    Tester    OnInit critical error

Alain Verleyen
36141
Alain Verleyen  
I confirm it. Please keep us posted. Thanks.
honest_knave
Moderator
2302
honest_knave  

I can confirm that your code runs on Build 1571, but has the invalid pointer access issue in Build 1580.

Tao Wu
595
Tao Wu  
John Emans:

Hi guys & gals,


As of 2017/04/07 the mql5 compiler produces binaries that almost instantly crash with a ' invalid pointer access' (or similar) error.

I can't claim that my code is bug-free, but it has been running for months, if not years, without much problems.

It's hard to give a code-snippet because the offending line is buried under layers of classes, but in essence it is something like:




So my questions:

* Is anyone aware of major changes in the MQL5 compiler?

* Is this the right place to discuss compiler problems?


Hello,
I confirm that the new mql5 compiler has introduced two bugs in my program today.
To add comments, please log in or register