On 6/29/2013 12:36 AM, Rainer Schuetze wrote:
> On 29.06.2013 06:38, Walter Bright wrote:
>>
>> On 6/27/2013 11:33 AM, Rainer Schuetze wrote:
>>> On 27.06.2013 19:04, Walter Bright wrote:
>>>>> IIRC you also have the GC handbook book on your shelf. Check the
>>>>> chapters on RC, especially algorithm 18.2 "Eager reference counting
>>>>> with
>>>>> CompareAndSwap is broken".
>>>>
>>>> I have the book, but it is the first edition and there's no chapter 18
>>>> in it :-(
>>>
>>> I can remove the dust from my scanner to copy the 3 mostly relevant
>>> pages and send them to you.
>>>
>>>
>
> I tried to scan it yesterday, but got large black bar at the fold (don't know if this the correct term) that eraased the first inch of text. I would have to rip the book apart to get better results.

Ah, don't rip up your book! (I cut the back off of mine and scanned it, but I no longer care to store the thousands of pounds of books I have anymore, and I like that my whole library fits on my laptop now!).

>
>>
>> I understand the issue (I think), but I can't think of a case where the
>> ref count would be 1 when this happens.
>>
>>
>
>
> Consider a global shared reference R that holds the last reference to an object O. One thread exchanges the reference with another reference P while another thread reads the reference into S.
>
> shared(C) R = O;      ; refcnt of O is 1
>
> in pseudo-assembly missing null-checks:
>
> Thread1 (R = P)        Thread2 (S = R)
>
>                        mov ecx,[R]
>                        ; thread suspended
> mov eax,[P]
> inc [eax].refcnt
> mov ebx,[R]
> mov [R],eax
> dec [ebx].refcnt      ; refcnt of O now 0
> jnz done
> call delete_ebx
>                        ; thread resumed
>                        inc [ecx].refcnt
> done:
>
> The increment on [ecx].refcnt modifies garbage.
>
>

Ok, I see. Let me think about it some more.

Reply via email to