Using Cinder-OpenNI UserApp sample


#1

I’ve been trying to utilize the openNI2 block discussed here:
https://forum.libcinder.org/topic/rfc-cinder-openni

and came across the same issue as christianrakete (last comment on the thread)
using the UserApp sample.
Has anyone manage to resolve this issue?

void release(){
if (m_pFrame != NULL){
niteUserTrackerFrameRelease(m_userTrackerHandle, m_pFrame); // <================
}
m_pFrame = NULL;
m_userTrackerHandle = NULL;
}

malloc: *** error for object 0x6080000a1f20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug


#2

m_pFrame is not NULL, yet points to invalid memory. This could have one of the following causes:

  • m_pFrame is not initialized to NULL on construction.
  • a copy was made of the instance holding m_pFrame, but the m_pFrame pointer wasn’t copied (check the copy constructor and/or the assignment operator of the class).
  • the instance holding m_pFrame was itself deleted, but the pointer to it was not reset to NULL, so upon calling release(), invalid memory was being read.
  • the instance holding m_pFrame could not be constructed in the first place, due to an out of memory error, but was used nonetheless.

Do a search on m_pFrame and see where it is set, read and/or written to. Then place breakpoints at suspicious pieces of code.


#3

Thank you Paul so much for your quick response, unfortunately only now I had the chance to test your ideas,
I’ve attempted creating a deep copy of the user frame originating from:

void UserApp::onUser( nite::UserTrackerFrameRef frame, const OpenNI::DeviceOptions& deviceOptions )

Basically adding:

if( !frame.isValid() )
return;

nite::UserTrackerFrameRef frameCopy = nite::UserTrackerFrameRef( frame );
frame.release();

Hoping this will work, I’m still suspecting
this is not completely thread safe, but will report my findings.