RemoveFreeBlock Null pointer

99 views
Skip to first unread message

Taha Liaqat

unread,
Nov 25, 2020, 4:38:43 PM11/25/20
to cmpt-295-sfu
SFU ID: tliaqat
Github username: tliaqat
Question: what is the expected behavior when we call removeFreeBlock on a block that is the only element in the freeList? There are not any null checks on  prevFree in removeFreeBlock. So I am getting a seg fault because my block is the only element, and its next and prev pointers are null.

ali sedaghati

unread,
Nov 26, 2020, 1:54:21 PM11/26/20
to cmpt-295-sfu
The logic of your removeFreeBlock function seems to be okay. Please use gdb to find out the source of the error.

Taha Liaqat

unread,
Nov 26, 2020, 4:27:07 PM11/26/20
to cmpt-295-sfu
the issue is, is that gdb told me the problem was in removeFreeBlock, Line 211.

Taha Liaqat

unread,
Nov 26, 2020, 4:27:38 PM11/26/20
to cmpt-295-sfu
so where do I go from here?

ali sedaghati

unread,
Nov 27, 2020, 4:25:23 PM11/27/20
to cmpt-295-sfu
Please put the output of examine_heap here.

ashrir...@gmail.com

unread,
Nov 27, 2020, 4:46:37 PM11/27/20
to cmpt-295-sfu
Check if the free block is != Free list head.
prev being null is not your problem. 

1) YOUR FREE_LIST_HEAD is not being set to NULL when you have run out of blocks. 
2) You may be potentially corrupting the free blocks next and prev when manipulating your allocated blocks. Check your size parameters.
Reply all
Reply to author
Forward
0 new messages