preethi selvaraju
preethi selvaraju

Reputation: 155

QNX OS - CPP Application: Error: Malloc Check Failed crash

I'm using QNX OS and my application is in C++. Am getting an error message as shown below and my program is crashing.

Malloc Check Failed: :/builds/workspace/QOS221-SDP/build_aarch64/lib/c/alloc/dlist.c:1057
Abort (core dumped)

I don't have dlist.c source code to check. The same application I have it in Windows and its working perfectly. Due to security reasons I'm not able to share the code.

I'm not double freeing the memory or NULL pointer. I've printed the ptr addresses the no.of bytes allocated during allocMemory. and when freeing also before deleting I've checked whether its not NULL and when I printed the ptr address and no.of.bytes allocated, it is showing the same.

After allocating:
newNumBytes:: ptr==>13eb4040::numBytes==>67584

Before deallocate:
deleteNumBytes:: ptr==>13eb4040::numBytes==>67584

deleteNumBytes(
    T&            ptr,
    const int32_t numBytes  
)
{
    // Here T is the pointer and and not the pointed type
    //
    static_assert(sizeof(T)   == sizeof(void*),"error");
    static_assert(sizeof(ptr) == sizeof(void*),"error");
    if (numBytes > 0)
    {
            if(ptr != NULL)
            {
                delete[] ptr;
                ptr = NULL;
            }        
    }
}

Everytime it is crashing on the same variable but that variable seems to be having valid memory address. Core dump is not useful. I don't have any tool like valgrind.

  1. Any hint on why its crashing?
  2. Is there anyway I could get dlist.c source code from QNX SDP?

Any help is appreciated.

Upvotes: 0

Views: 1371

Answers (0)

Related Questions