mm-realloc

180 views
Skip to first unread message

brandon

unread,
Nov 26, 2020, 5:58:31 PM11/26/20
to cmpt-295-sfu
SFU ID: 301358970
Github username:bla118
Github: Link to github repo (your assignment repos are private so these links are only accessible to TAs and Instructor)
Line and file: 
Expected behavior:
Observed behavior: Data from old block not preserved
Question: Could you please check if i'm approaching realloc correctly, thanks

ali sedaghati

unread,
Nov 27, 2020, 4:34:48 PM11/27/20
to cmpt-295-sfu
Please post the output of examine_heap here.

brandon

unread,
Nov 27, 2020, 4:40:41 PM11/27/20
to cmpt-295-sfu

ashrir...@gmail.com

unread,
Nov 27, 2020, 4:49:04 PM11/27/20
to cmpt-295-sfu
Copying is broken.
Try casting to a type before copying.

brandon

unread,
Nov 27, 2020, 9:08:54 PM11/27/20
to cmpt-295-sfu
ok, I believe I have type casted it correctly however I am not sure how to fix this new problem.
 

ashrir...@gmail.com

unread,
Nov 29, 2020, 10:59:16 PM11/29/20
to cmpt-295-sfu
I just ran your repo SHA: e7ee90469220ae3c0e8541582a52630fa0501b0e
Checking mm_malloc for correctness, ERROR [trace 0, line 7]: mm_realloc did not preserve the data from old block
Seems like your copying is broken. You may want to check the ptr returned by realloc or whether you are copying the correct bytes in the payload or the copy loop.

brandon

unread,
Nov 29, 2020, 11:44:03 PM11/29/20
to cmpt-295-sfu
ok, it appears that shortrealloc trace works but seg faults for reallocbal. Is there something else i'm missing? thanks

ashrir...@gmail.com

unread,
Nov 29, 2020, 11:49:02 PM11/29/20
to cmpt-295-sfu
Obviously, we are not magicians to say by just staring at code :)
If you attach the output examine_heap and specify what steps you took and observed we can potentially help.

brandon

unread,
Nov 30, 2020, 12:59:53 AM11/30/20
to cmpt-295-sfu
i've checked the values in both blocks and they seem to have the correct values. Below is the output of examineheap 

brandon

unread,
Nov 30, 2020, 1:03:09 AM11/30/20
to cmpt-295-sfu

Arrvindh Shriraman

unread,
Nov 30, 2020, 5:42:34 PM11/30/20
to cmpt-295-sfu
Clearly as can be seen; your size went out of whack on the free block.
You seem to be updating size field with a pointer
Reply all
Reply to author
Forward
0 new messages