Memory error occurs when using .resize() in setup()

Hello everyone,

I’m having an error on my console which I’ve never seen before.

2020-12-28 19:40:22.407295+0100 myTest_01Debug[2445:57535] Metal API Validation Enabled
myTest_01Debug(2445,0x10099d5c0) malloc: Incorrect checksum for freed object 0x101015200: probably modified after being freed.
Corrupt value: 0xbd01ad1dbd8012d1
myTest_01Debug(2445,0x10099d5c0) malloc: *** set a breakpoint in malloc_error_break to debug
(lldb) 

which disappears when I disable this line of my code in ofApp::setup():


// some more code
myVector.resize(rows*cols);   // <- this line
// some more code

The error comes out after the compiling is finished, and this code block is pointed(in ofAppGLFWWindow):

void ofAppGLFWWindow::update(){
	events().notifyUpdate();

	//show the window right before the first draw call.
	if( bWindowNeedsShowing && windowP ){
		glfwShowWindow(windowP);             //Thread 1: signal SIGABRT
		bWindowNeedsShowing = false;
		if(targetWindowMode==OF_FULLSCREEN){
			setFullscreen(true);
		}
	}

Weird thing is that, it occurs randomly(?) when I build with the same code.

The app runs clear only when I replace this line

myVector.resize(rows*cols);

with this:

for(int i=0; i<rows*cols; ++i){
    myVector.push_back(0);
}

So it apparently comes from .resize()

I could use the .push_back() as I’m doing it only in the setup(). But I just wonder why this is happening.

Any tip for this error?
Thanks in advance!