Hazard pointers needed with GC ?

Timon Gehr timon.gehr at gmx.ch
Wed Dec 7 14:15:08 PST 2011


On 12/07/2011 06:02 PM, Martin Nowak wrote:
> I implemented a lock-free doubly linked list some time ago.
> I omitted the use of hazard lists because flagging the lowest
> bit would still make a valid pointer into the list node.
> Afterwards I found that
> http://www.d-programming-language.org/garbage.html explicitly states:
> p = cast(void*)(cast(int)p | 1); // error: undefined behavior
>
> Is this really needed? Guess the current GC would work properly.
>
> Also if a list node were
> Node(T)
> {
> ubyte[2] data;
> T t;
> }
> Than both a pointer to data[0] as well as one to data[1] are valid
> and effectively hold the node.
>
> martin

TDPL suggests that using that kind of pointer flagging is sane. Maybe 
you can file a bug against the specification.


More information about the Digitalmars-d mailing list