LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NumericArrayResize crash

What's wrong when NumericArrayResize CIN function crashed. The weird thing is that it didn't crash until I recompiled my DLL made in Labview. The code crashes at NumericArrayResize call even if I don't call my labview DLL. I extracted the relevant parts of the code to below.

#include "extcode.h"
typedef struct {
    long dimSize;
    double Value[1];
    } TD3;
typedef TD3 **TD3Hdl;

void NervusFile::Crash(void)
{

      TD3Hdl dtHdl=NULL;
      long channels = 32;
      dtHdl= (TD3Hdl)(DSNewHandle(sizeof(TD3)));
         NumericArrayResize(0x0A, 1, (UHandle *) &dtHdl, channels);
}

--
Tomi Maila
0 Kudos
Message 1 of 4
(2,809 Views)


@Tomi M wrote:
What's wrong when NumericArrayResize CIN function crashed. The weird thing is that it didn't crash until I recompiled my DLL made in Labview. The code crashes at NumericArrayResize call even if I don't call my labview DLL. I extracted the relevant parts of the code to below.

#include "extcode.h"
typedef struct {
    long dimSize;
    double Value[1];
    } TD3;
typedef TD3 **TD3Hdl;

void NervusFile::Crash(void)
{

      TD3Hdl dtHdl=NULL;
      long channels = 32;
      dtHdl= (TD3Hdl)(DSNewHandle(sizeof(TD3)));
         NumericArrayResize(0x0A, 1, (UHandle *) &dtHdl, channels);
}




NumericArrayResize can allocate a new handle when passed in a NULL handle. And it is always a good idea to actually
check your error return values. Last but not least since you are using C++ here your Crash method might be invoked somehow through the constructor of your object. Hard to say without seeing all the code.

MgErr NervusFile::Crash(void)
{

      TD3Hdl dtHdl=NULL;
      long channels = 32;
      MgErr err =  NumericArrayResize(fD, 1, (UHandle *) &dtHdl, channels);

      /* since the handle is not passed out it would be a good idea to actually deallocate it again.
         Are you sure this method is not somewhere called in a circular reference over and over again,
         which would create an out of mem condition at some point? */
      if (!err)
         err = DSDisposeHandle(
dtHdl);

      return err;
}

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(2,782 Views)

rolfk:NumericArrayResize can allocate a new handle when passed in a NULL handle.

 

I'm not shure you are right, please look here

Is there a bug in arrresize.c and in the documentation?

0 Kudos
Message 3 of 4
(2,451 Views)

kolan wrote:

rolfk:NumericArrayResize can allocate a new handle when passed in a NULL handle.

 

I'm not shure you are right, please look here

Is there a bug in arrresize.c and in the documentation?


I'm not sure what you try to show in that other thread. For me it simply lacks any consistent theme and context.

 

But I'm 100% sure that the NumericArrayResize() function that is exported by the LabVIEW kernel will work properly with this code:

 

UHandle h = NULL;

MgErr err = NumericArrayResize(uB, 1, &h, size);

 

and allocate an according handle of size bytes. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(2,423 Views)