|
|
Log in / Subscribe / Register

Provenance

Provenance

Posted Oct 15, 2024 23:36 UTC (Tue) by dcoutts (subscriber, #5387)
In reply to: Provenance by tialaramex
Parent article: Zapping pointers out of thin air

Quite often when I read these kinds of (fascinating) articles about the intricacies of concurrent lock free programming in C/C++, I come away thinking smugly to myself "it isn't a problem in my favourite GC'd language".

As far as I've understood, the ABA problem can't occur in a GC'd language, because the memory location cannot get recycled by the storage manager since there's still a live reference to the old object. The same goes for the "zombie pointer" example:

> Then, the thread is preempted, and a second thread clears the whole stack. It processes the entries, and frees A. Now A is on the free list, but B still points to it.

In a GC'd language this doesn't happen. B still pointing to A keeps A live. Thus the memory location for A cannot yet be reused. And thus C will necessarily have a different address from A and so the CAS will do the right thing.

Obviously, one has to pay the GC performance tax. But having done so, it appears one can take advantage of lock free programming much more easily. Am I wrong to be so smug? Is this dangerous over-simplification?


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds