问题
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