Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the meaning of `malloc(): corrupted top size`

I am trying to append a struct pointer to a dynamically allocated array. After that I return the struct pointer that was added to the array. This is then dereferenced and put into a variable that I want to print out. My problem is that when I try to access a value (i.e. struct.id) the compiler tells me malloc(): corrupted top size and Aborted (core dumped).

Everywhere I have looked so far simply answered how to fix the problem, but I can’t seem to figure out what it actually means or just find very vague definitions that don’t help me. Also none of the solutions work for my specific condition.Aborted (core dumped)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

What is the meaning of malloc(): corrupted top size

It means that your program has invoked Undefined Behaviour most likely by accessing the allocated memory block outside its bounds.

But it can also be caused by something else (for example unrelated memory access changing the memory containing malloced memory metadata).

Also none of the solutions work for my specific condition.Aborted
(core dumped)

It is one of the ways UB can express itself. It is not "your condition". You need to find what is invoking the UB.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading