pr_trunks problem

October 2, 2005

Bug remaining in the current Gc source that I will fix tomorrow:

The pr_trunk NULL problem.

The pr_trunk, used to resolve a pointer into a managed object to the head of that managed object, can cause problems when one entry of it is NULL.

Two structures are used to resolve a pointer to a managed object to the head of that managed object. pr_offsets and pr_trunks. pr_offsets contains the relative offset of all allocated blocks a.k.a ablocks in the managed heap relative to the pr_trunk its in. Each pr_trunk covers 64KiB of memory of the managed heap.

A pointer is resolved by first making it relative to the start of the managed heap (pointer – mheap). Then getting the pr_trunk it’s in ((pointer – mheap) / 65536). The trunk itself points into the pr_offsets array. By getting the pr_trunk next to the current trunk the amount of allocated blocks inside the trunk can be found. When this is known a simple binary search can be used to find the allocated block.

When a pr_trunk doesn’t contain any allocated blocks it becomes NULL. This behaviour screws up the trunk count lookup and the move to the left trunk when this trunk doesn’t contain it behaviour.

So I got to fix this.

First thing tomorrow morning.

When I had some coffee.

Advertisements