sbrk(0) value getting increased after calling printf

青春壹個敷衍的年華 提交于 2021-02-11 07:43:36

问题


I am trying to write my own malloc implementation, following an online course. Issue I am facing is that i always get segmentation fault, and when i tried to debug it always point to printf statement, which is just a string. After further investigation i found the value for sbrk(0) always increase after printf gets called.

I am not sure but i think my malloc implementation overwrites some memory space that printf might be using. But is it possible for printf to be there.

The program works fine when there is no printf.

I am using sbrk(size) to increase the size of heap.

Eg. heap before calling printf was 0x604000 to 0x605000 and after calling it was 0x604000 to 0x626000

来源:https://stackoverflow.com/questions/39735859/sbrk0-value-getting-increased-after-calling-printf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!