Can sbrk and malloc be used in the same program?

Florian Weimer fw@deneb.enyo.de
Wed Aug 12 13:55:58 GMT 2020


* 孙世龙 sunshilong via Libc-help:

> As per the representation(https://my.eng.utah.edu/~cs4400/malloc.pdf,
> page 3),  which says:
> Do not use sbrk in a program that also uses malloc or anything that
> calls malloc (such as print).
>
> Is it right?
> If it's right, why?

The malloc implementation assumes that it has complete control over
the program break.  Things go wrong if the break is modified outside
its control.


More information about the Libc-help mailing list