cancel
Showing results for 
Search instead for 
Did you mean: 

_BLOCK_TYPE_IS_VALID or HEAP mismatch using std::vector as return value in UDO

Experimenter
Experimenter

Hello,

 

I'm facing a real big problem right now while trying to use UDOs in C++.

 

When I'm trying to receive for example the double array from some UDO, I'm getting a _BLOCK_TYPE_IS_VALID != etc. error in the debug version.

 

typedef vector<double> doublearray;
 
bool getDouble(string name, double &result) {
   doublearray mydoubles=m_theUDO->GetDoubles();
 
   return true;
} // if (mydoubles.size() > 0) ->Crash here 


 I get that with NX 8 and NX 9. 

 

When I am creating a small example with the wizard everything works ok, as long as I use the right compiler (NX8=VS2010 and NX9=VS2012). If not, it is crashing  at this point too.

 

In my current project I have the same settings, but it keeps crashing.

 

I also have to compile it with /MD otherwise some other artifacts occur.


When I follow the stack trace, it is crashing when the STL tries to deallocate the data. This can be when the memory is allocated with something different than with what it was created.

I have no idea what NX does internally. But I think passing back the array via STL Vectors was a really bad idea. 

 

I hope somebody knows a workaround for this or has some valuable information that could help me solving it.

 

Thank you,

Markus