Login Page - Create Account

Support Board


Date/Time: Thu, 28 Mar 2024 14:51:22 +0000



Post From: Custom Studies has issue on windows 10

[2019-10-19 16:52:53]
binaryduke - Posts: 351
Attached please find:

- custom study that has been compiled as a debug build
- two specimen chartbooks - one simple, one more complex

The simple chartbook will quite consistently cause heap corruption when the chartbook is closed. We have traced this behaviour to after the following code runs, i.e. when the function returns from the test of sc.LastCallToFunction. Dynamic memory is allocated for two arrays of structs as follows:



struct s_v
  {
   int a, b, c, d, e, f, g, h, i, j;
  };

struct s_e
  {
   int z, y, x, w, v, u;
  };

  std::vector<s_v>* p_v = (std::vector<s_v>*)sc.GetPersistentPointer(1);
  std::vector<s_e>* p_e = (std::vector<s_e>*)sc.GetPersistentPointer(2);

  //Allocate dynamic memory
  if (sc.LastCallToFunction)
  {
    if (p_v != NULL)
    {
      delete p_v;
      sc.SetPersistentPointer(1, NULL);
    }
    if (p_e != NULL)
    {
      delete p_e;
      sc.SetPersistentPointer(2, NULL);
    }
    return;
//after closing the simple chartbook, this is when a hang occurs
  }

  if (p_v == NULL)
  {
    p_v = new std::vector<s_v>;

    if (p_v != NULL)
      sc.SetPersistentPointer(1, p_v);
    else
    {
      sc.AddMessageToLog("Memory allocation error 1", 1);
      return;
    }
  }

  if (p_e == NULL)
  {
    p_e = new std::vector<s_e>;

    if (p_e != NULL)
      sc.SetPersistentPointer(2, p_e);
    else
    {
      sc.AddMessageToLog("Memory allocation error 2", 1);
      return;
    }
  }

The supplied study and chartbooks all work well in v1991.

The study will need activation per the supplied notes in post #6. It would be appreciated if you would check the debug version so we can understand whether there is anything amiss from our side or if it helps identify any issue in v1997.
Date Time Of Last Edit: 2019-10-19 16:53:18
Private File
Private File
Private File